Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vb.net character set

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

alt text

  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?
like image 204
Connor Albright Avatar asked Jan 22 '23 02:01

Connor Albright


1 Answers

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.

like image 191
Heinzi Avatar answered Jan 30 '23 10:01

Heinzi