Disappearing code

I have lines of code with unicode characters that are not visible in the IDE.

Take for example the following.

string s3;
s3 = Devex(" "); //Devex is just a function that returns a string
Console.WriteLine(s3);
MessageBox.Show(" ")); //you have been denied!

appears like this in the IDE:

string s3;

Console.WriteLine(s3);

The code is correct if you open it in Notepad. It executes properly. You can't cursor forward on the line but you can cursor backwards.

I am using VS2005 on a Vista box. I didn't have this problem on an XP box. I've checked all the setting under Tools/Options between the two boxes and they all match. This is not specific to C#. The same thing happens if I try this in VB.

What is causing this, and how can I fix it



Answer this question

Disappearing code

  • patio87

    dermeister wrote:

    I am using VS2005 on a Vista box. I didn't have this problem on an XP box.

    It might be a simple font problem. Some fonts don't support unicode. Try 'Tools', 'options', 'font and colors' to see what font the editor uses. I know that 'Arial' and 'Courier new' support unicode, while 'tahoma' doesn't, at least on my xp comp.

    Another solution could be that you have different international settings on the two comp (Control Panel). If the settings on the xp computer is say japanese, then it will save files using a japanese encoding by default (because japanese characters will be part of the 'CURRENT' codepage, no need for unicode). Now when read on a say english comp. these characters does not belong to the current codepage and since the file was not saved in unicode, they can't be loaded correct.

    Hope this helps.



  • ZopoStyle

    It is checked. I've tried that both ways with no effect.
  • erikkl2000

    When the file is opened in the IDE, click the File menu and the Advanced Save Options... item. What do you see If it's not set to Unicode, try changing it to unicode.

  • Dual Cortex

    Strange. Sounds like the file isn't stored in Unicode (or there's a bug in Visual Studio). Have a look in Tools\Options, Text Editor\General, check to see if Auto-detect UTF-8 encoding without signature is checked.

  • Dr.Virusi

    After adding the Advanced Save Options... item to my File menu, I checked the settings. It was already set to Ecoding: Unicode - Codepage 1200 and Line Endings: Current Setting. I also tried Unicode (Big Endian) - Codepage 1201. Neither had any effect.
  • Disappearing code