开发者

vb.net character set

开发者 https://www.devze.com 2023-01-25 21:56 出处:网络
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 u开发者_C百科ses the one and uses the other?

According to MSDN vb.net uses this extended character set. In my experience it actually uses this:

vb.net character set

  1. What am I missing? Why does it say it u开发者_C百科ses 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.


The first character set is Code Page 437 (CP437), the second looks like Code Page 1252 (CP1252) also known as Windows Latin-1.

I'd guess VB.Net is simply picking up the default encoding for the PC.


How did you write all this? Because usually, when you use a output stream function, you can specify the encoding going with it.

Edit: I know this is not C#, but you can see the idea...

You'd have to set the encoding of your filestream, by doing something like this: Setting the encoding when creating the filestream

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号