I've tracked a problem I'm having down to the following inexplicable behaviour within the .NET System.Text.Encoding class:
byte[] original = new byte[] { 128 };
string encoded = System.Text.Encoding.UTF8.GetString(original);
byte[] decoded = System.Text.Encoding.UTF8.GetBytes(encoded);
Console.WriteLine(original[0] == decoded[0]);
Am I expecting too much that decoded should equal original in the above?
UTF8, UTF7, UTF32, Unicode and ASCII all produce various varieties of wrongness. What's going on?