Encoding.GetEncoding(437).GetString() bug?

Viewed 6041

I have following test program

char c = '§';
Debug.WriteLine("c: " + (int)c);

byte b = Encoding.GetEncoding(437).GetBytes("§")[0];
Debug.WriteLine("b: " + b);

char c1 = Encoding.GetEncoding(437).GetString(new byte[] { 21 })[0];
Debug.WriteLine("c1: " + (int)c1);

This produces following result:

c: 167
b: 21
c1: 21

As I can see here GetBytes is working correctly
167 in unicode => 21 in CP437
but GetString is not working
21 in CP437 => 21 in unicode

Is this a bug or my mistake?

2 Answers
Related