I have following test program
char c = \'§\';
Debug.WriteLine(\"c: \" + (int)c);
byte b = Encoding.GetEncoding(437).GetBytes(\"§\")[0];
Debug.WriteLine(\"b:
.net supports two different characters, both of which are (usually) rendered as §
:
char c1 = (char)21;
char c2 = (char)167;
Console.WriteLine(c1 == c2); // prints false
Console.WriteLine(c1); // prints §
Console.WriteLine(c2); // prints §
Character 21 is a special control character, which is rendered as §
when output in text mode.
CP437 allows for 21 to be interpreted as either a control character or as the literal §
. Apparently, GetString
chooses to interpret it as the control character (which is a perfectly valid option), and, thus, maps it to the Unicode control character 21 rather than to the Unicode literal §
.