Windows 7 x64 and Oracle Client

I installed my Windows 7 x64 this weekend and so far everything is great. Much better than when I was running on Vista.

I thought I had run into my first problem with 7 when was setting up my Oracle connection. I installed the Oracle Client 11g x64 successfully, I could even connect to the database using SqlPlus. My Visual Studio on the other hand disagreed. When I tried to configure a connection to my Oracle server I got the following error:

Exception: Attempt to load Oracle client libraries threw
BadImageFormatException. This problem will occur when running in 64
bit mode with the 32 bit Oracle client components installed

This was weird, after all I could connect to the database through SqlPlus, right? The problem is that VS2008 is 32 bit and as such it needs a 32 Oracle Client in order to connect to the db. When I installed the 32 bit client VS was able to connect to the db on the spot. So the only problem I had with Windows 7 so far had nothing to do with Windows 7, in fact you would run into the same situation in any other 64 bit version of Windows.

 

Find and Replace using Regular Expressions within Visual Studio

Regular expressions can be a great addition to the Find and Replace functionality within Visual Studio, specially when you want do do some transformation on the text you are looking up. Lately I’m working on a simple conversion class to transform some HTML into RTF. I got a list of special characters in HTML that I had to convert to the RTF equivalent and for that I needed to create a dictionary. The values where listed in a text document like this:

\'b0 \tab °\par
\'b1 \tab ±\par
\'b2 \tab ²\par
\'b3 \tab ³\par
\'b4 \tab ´\par
\'b5 \tab µ\par
\'b6 \tab ¶\par
\'b7 \tab ·\par
\'b8 \tab ¸\par
\'b9 \tab ¹\par
\'ba \tab º\par
\'bb \tab »\par
\'bc \tab ¼\par
\'bd \tab ½\par
\'be \tab ¾\par

And I needed to create a dictionary with the key being the HTML code (third column) and the RTF code (first column) the value. Like this:

Dictionary<string, string> charsMapping = 
    new Dictionary<string, string>();
charsMapping.Add("&euro;", @"\'80");

Here is the expression to find the matches within Visual Studio: __ {\\’:a:a}{.}{&:a;}{\\par}

Each pair of { } is a group to be matched. The difference is that the usual \w (letters or numbers) is :a. In my expression I have four groups the fist is the match for the RTF character and the third is the match for the HTML code. Knowing that the Replace expression is as follows: __charsMapping.Add(”\3”, @”\1”);

Here is how it would look like in VS:

Doing this is much easier then creating the dictionary by hand of even writing a console app to do the replace. Sure I could have used some other text tool to do the same but it wouldn’t be as much fun as figuring out how to do it in VS.

Here is the final output:

Dictionary<string, string> charsMapping = 
    new Dictionary<string, string>();
charsMapping.Add("&deg;", @"\'b0");
charsMapping.Add("&plusmn;", @"\'b1");
charsMapping.Add("&sup2;", @"\'b2");
charsMapping.Add("&sup3;", @"\'b3");
charsMapping.Add("&acute;", @"\'b4");
charsMapping.Add("&micro;", @"\'b5");
charsMapping.Add("&para;", @"\'b6");
charsMapping.Add("&middot;", @"\'b7");
charsMapping.Add("&cedil;", @"\'b8");
charsMapping.Add("&sup1;", @"\'b9");
charsMapping.Add("&ordm;", @"\'ba");
charsMapping.Add("&raquo;", @"\'bb");
charsMapping.Add("&frac14;", @"\'bc");
charsMapping.Add("&frac12;", @"\'bd");
charsMapping.Add("&frac34;", @"\'be");
charsMapping.Add("&iquest;", @"\'bf");

Of course the number of characters was much bigger but it doesn’t matter here. If you need more info on regular expressions you might want to check out the Regular-Expressions.info site, they have a lot of good info on the subject. There are some specifics to using regular expressions on VS so you need to make sure to visit MSDN Reference.

jQuery Intellisense in VS 2008

Microsoft has shipped a patch to Visual Studio 2008 and Visual Web Developer 2008 Express that enables intellisense support for jQuery and will allow developers to add configuration information to other libraries such as Prototype so that they too can have the intellisense support. Read more about it in ScottGu’s Blog