views:

135

answers:

1

I'm programming in VB.NET using Visual Studio 2008. I need to define a string literal containing the character "÷" equivalent to Chr(247). I understand that internally VS uses UTF-16 encoding, but when the source file is written to disk it contains the single byte value F7 for this character.

This source file is processed by another program that uses UTF-8 encoding by default, so it fails to interpret this character correctly, attempting to combine it with the following single-byte character. What encoding would correctly interpret the single byte F7 as the single character ÷?

Alternatively, is there a way of expressing a non-ASCII literal that uses only ASCII characters - like using some kind of escape sequence?

+3  A: 

well, i always thought that by default VS uses UTF-8 to save files. But ÷ is F7 in encoding ISO 8859-1. If this is not enough for you go here: http://stackoverflow.com/questions/840065/how-to-change-source-file-encoding-in-csharp-project-visual-studio-msbuild-mac

Andrey
If you aren't specifying encoding then the file is written in ASCII(7 bit data). For the full ASCII character set I use winndows-1252 encoding.
dbasnett
In the Western European locale, VS2008 uses the Windows code page to save files unless there are characters that won't fit! So many thanks, that was exactly the pointer I needed.
Nick
@dbasnett, no. i can be sure only about C# editor in VS, because i mainly use it. so, it saves in UTF-8, which is backward compatible with ASCII.
Andrey