如何定义包含非 ASCII 字符的字符串文字?
我正在使用 Visual Studio 2008 在 VB.NET 中进行编程。 我需要定义一个包含相当于 Chr(247) 的字符“÷”的字符串文字。 我知道VS内部使用UTF-16编码,但是当源文件写入磁盘时,它包含该字符的单字节值F7。
该源文件由另一个默认使用 UTF-8 编码的程序处理,因此它无法正确解释该字符,尝试将其与后面的单字节字符组合。 什么编码可以正确地将单字节 F7 解释为单个字符 ÷?
或者,是否有一种方法来表达仅使用 ASCII 字符的非 ASCII 文字 - 例如使用某种转义序列?
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?
嗯,我一直以为VS默认使用UTF-8来保存文件。但 ÷ 在编码 ISO 8859-1 中是 F7。如果这对您来说还不够,请转到此处: 如何更改csharp项目(Visual Studio / msbuild机器)中的源文件编码?
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: how to change source file encoding in csharp project (visual studio / msbuild machine)?