Hi All,
I was migrating an app from 1.0 to 3.5 and testing in 4.0. It seems the following behavior has changed when it comes to the iso-2022-jp and SHIFT_JIS encoding routine.
If you run the following routine on 1.0 you end up with "true", however, if you run it on 3.5, you end up with "false".
This is a real show stopper for me, because something is broken somewhere. I can't believe I'm the first one that is discovering this, so I must be missing something (I can't find anything on google).
Here is the code example:
byte[] data = new byte[] { 137, 186, 139, 76, 138, 136, 147, 174, 130, 201, 130, 194, 130, 162, 130, 196, 147, 93, 145, 151, 130, 181, 130, 220, 130, 183 };
string iso2022String = Encoding.GetEncoding("iso-2022-jp").GetString(data);
string shiftJisString = Encoding.GetEncoding("Shift_JIS").GetString(data);
if (iso2022String == shiftJisString)
Console.WriteLine("true");
else
Console.WriteLine("false");
In 1.0 the iso2022String has the same values as the shiftJisString. You can write them out in the debugger to verify. In 3.5, Console.WriteLine( "false" ) is executed, and the values of 2 different strings are shown.
Can anyone shed some light on this?
Thanks,
Dave
PS: I have no idea what the text means, so I hope it isn't inflammitory. I just used some Japanse characters I came across.