问题描述
我使用Visual Studio 2008在VB.NET中编程。
我需要定义一个字符串文字,其中包含等同于Chr(247)的字符÷。
我理解内部VS使用UTF-16编码,但是当源文件写入磁盘时,它包含该字符的单字节值F7。
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.
此源文件由默认使用UTF-8编码的另一个程序处理,因此无法正确解释此字符,尝试将其与以下单字节字符组合。
什么编码会将单个字节F7正确解释为单个字符÷?
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 ÷?
或者,是否有一种表达非ASCII字面值的方法, ASCII字符 - 像使用某种转义序列?
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-保存文件。但是÷在编码ISO 8859-1中是F7。如果这还不够,您可以在这里:
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)?
这篇关于如何定义包含非ASCII字符的字符串文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!