vb.net字符集 [英] vb.net character set

查看:390
本文介绍了vb.net字符集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据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 命令:


出现在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:

  1. What am I missing? Why does it say it uses the one and uses the other?
  2. Am I doing something wrong?
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆