如何定义包含非 ASCII 字符的字符串文字?

发布于 2024-09-02 06:24:35 字数 280 浏览 1 评论 0原文

我正在使用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

临走之时 2024-09-09 06:24:35

嗯,我一直以为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)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文