vb.net字符集 [英] vb.net character set
问题描述
根据MSDN :
返回值取决于当前线程的代码页,它包含在System.Globalization命名空间中TextInfo类的ANSICodePage属性中。您可以通过指定System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage获取ANSICodePage。
因此,输出<$ c $对于大于127的值,c> Chr 是系统相关的。如果您想要可重现的结果,请通过调用 Encoding 实例。 aspx> Encoding.GetEncoding(String),然后使用 Encoding.GetChars(Byte()) 将数字值转换为字符。
如果您在你的问题中链接的图表上升一级,你会看到他们不声称这个图表总是 Chr $ c $的输出c>命令:
出现在Windows上方的字符取决于所选的字体。
本节中的图表显示控制台应用程序的默认字符集。
您的应用程序是一个WinForm应用程序,而不是控制台应用程序。即使在控制台中,可以更改使用的字符集(例如,使用 chcp
命令),因此单词default。
有关.net中使用的编码的详细信息,我推荐以下MSDN文章: .NET Framework中的字符编码。
According to MSDN vb.net uses this extended character set. In my experience it actually uses this:
- What am I missing? Why does it say it uses the one and uses the other?
- Am I doing something wrong?
- Is there some sort of conversion tool to the original character set?
This behaviour is defined in the documentation of the Chr
command:
The returned value depends on the code page for the current thread, which is contained in the ANSICodePage property of the TextInfo class in the System.Globalization namespace. You can obtain ANSICodePage by specifying System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage.
So, the output of Chr
for values greater than 127 is system-dependent. If you want reproducible results, create the desired instance of Encoding
by calling Encoding.GetEncoding(String), then use Encoding.GetChars(Byte()) to convert your numeric values into characters.
If you go up one level in the chart linked in your question, you will see that they do not claim that this chart is always the output of the Chr
command:
The characters that appear in Windows above 127 depend on the selected typeface.
The charts in this section show the default character set for a console application.
Your application is a WinForm application, not a console application. Even in the console, the character set used can be changed (for example, by using the chcp
command), hence the word "default".
For detailed information about the encodings used in .net, I recommend the following MSDN article: Character Encoding in the .NET Framework.
这篇关于vb.net字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!