-
Bug
-
Resolution: Duplicate
-
P4
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Tried latest 1.8.0 also.
A DESCRIPTION OF THE PROBLEM :
Decoding a byte array to a string using the charset "MS50220" fails to decode some characters which the real Microsoft code page 50220 can decode.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should print:
鄧
If there is any doubt, here is the equivalent program written in C#, and you can run it here:
https://dotnetfiddle.net/zDmDiG
namespace test
{
class MainClass
{
public static void Main(string[] args)
{
byte[] data = { 0x1B, 0x24, 0x42, 0x7B, 0x7D, 0x1B, 0x28, 0x42 };
string str = System.Text.Encoding.GetEncoding(50220).GetString(data);
System.Console.WriteLine(str);
}
}
}
ACTUAL -
Actually prints what looks like nothing, but it seems to be a special character.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Test
{
public static void main(String[] args) throws Exception
{
byte[] data = { 0x1B, 0x24, 0x42, 0x7B, 0x7D, 0x1B, 0x28, 0x42 };
String str = new String(data, "MS50220");
System.out.println(str);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use "x-windows-iso2022jp" instead of "MS50220" . But easier said than done when the code page declaration is inside a file parsed by someone else's code.
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Tried latest 1.8.0 also.
A DESCRIPTION OF THE PROBLEM :
Decoding a byte array to a string using the charset "MS50220" fails to decode some characters which the real Microsoft code page 50220 can decode.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should print:
鄧
If there is any doubt, here is the equivalent program written in C#, and you can run it here:
https://dotnetfiddle.net/zDmDiG
namespace test
{
class MainClass
{
public static void Main(string[] args)
{
byte[] data = { 0x1B, 0x24, 0x42, 0x7B, 0x7D, 0x1B, 0x28, 0x42 };
string str = System.Text.Encoding.GetEncoding(50220).GetString(data);
System.Console.WriteLine(str);
}
}
}
ACTUAL -
Actually prints what looks like nothing, but it seems to be a special character.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Test
{
public static void main(String[] args) throws Exception
{
byte[] data = { 0x1B, 0x24, 0x42, 0x7B, 0x7D, 0x1B, 0x28, 0x42 };
String str = new String(data, "MS50220");
System.out.println(str);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use "x-windows-iso2022jp" instead of "MS50220" . But easier said than done when the code page declaration is inside a file parsed by someone else's code.
- duplicates
-
JDK-8166257 Invalid conversion for PUA on x-windows-50220 and x-windows-50221
- Open