Wednesday, August 27, 2008

Asp include file causing wrong encoding

We faced this interesting problem in while developing our website. There are 2 different pages that show address fields - in Korean characters. Both are read from the same table. Problem is these korean characters that appears properly one of the page and other one it is garbled.

First I thought the encoding is not set properly in the page. So after spending sometime to trace to see if we are not setting the page culture - we were in the same old state where the characters appears inconsistent. Same piece of code on both the asp but even we set the encoding properly the content is garbled in one case. Could that be a virus?

You will be surprised - if you were not - atleast I was surprised to know that an include on top of the asp page was causing issue. If we remove a particular asp include in that page - the page renders properly. Ok thought that include file has some code that corrupts the encoding or character or something. Nothing of that sort.

Ok so what next? I had no idea and neither my friend. Then it struck that the ASP file while saving from Editor itself can have encoding specified and this can affect the encoding. There is something called UTF-8 BOM(Byte Order Mark). Some of the editor when we save the file would add this BOM and usually is not seen in some of the editors - it hides the character. I have noticed this character appear in VSS file version comparer. It often looks like "" - in case you get to see - at the beginning of the file. So if you have this character then it affects ASP encoding and causing above behaviour to appear.

Removing BOM - check here

Quickest thing to do was create a notepad file and copy pasted the content of the original file and overwrite the problem causing file. This fixed the problem.

Wednesday, April 02, 2008

TFS 2005 + VS 2008 - Trying to get them work together?

We had problem setting up CI. Had difficulty in setting up CI in TFS 2005 for VS 2008 solution. They are incompatible. MSBuild of TFS 2005 does not support VS 2008 solution. If your TFS build log had the below error,

... File format version is not recognized. MSBuild can only read solution files between versions 7.0 and 9.0, inclusive.

Then here are few things you can try.

Upgrading TFS 2008 looks like a safe thing to do – claim is that it is backward compatible.

If upgrade is not possible, below solution looks like a quicker and safer (as this would be applicable only to our project) solution to begin with (but it is a hack and I hope the unit test and code analysis also works)