-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
java version "1.4.2_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_14-b05)
Java HotSpot(TM) Client VM (build 1.4.2_14-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional Service Pack 2
A DESCRIPTION OF THE PROBLEM :
Shift_JIS encoder can not convert the Unicode character '\uFF0D' which is the fullwidth hyphen (minus) character into Shift-JIS character set (character code 0x817C in Shift-JIS).
When I tried to convert it vice-versa, Shift-JIS character 0x817C was converted into Unicode character \u2212 which is wrong. I think the mapping between Unicode and Shift_JIS has wrong information.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The above code should show the following message.
Unicode Character Data: \uFF0D
Shift_JIS Character Data: 0x81 0x7C
ACTUAL -
Conversion fails due to CharacterCodingException as follows.
Unicode Character Data: \uFF0D
java.nio.charset.UnmappableCharacterException: Input length = 1
at java.nio.charset.CoderResult.throwException(Unknown Source)
at java.nio.charset.CharsetEncoder.encode(Unknown Source)
---------- BEGIN SOURCE ----------
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class Test {
/** Creates a new instance of Test */
public Test() {
char c = '\uFF0D'; // Fullwidth Hyphen-Minus, 0x817C in Shift-JIS
CharsetEncoder ce = Charset.forName("Shift_JIS").newEncoder();
CharBuffer cb = CharBuffer.allocate(1);
ByteBuffer bb;
System.out.println(String.format("Unicode Character Data: \\u%X", new Integer(c)));
cb.put(c);
cb.rewind();
try
{
bb = ce.encode(cb);
System.out.print(ce.charset().displayName() + " Character Data: ");
while (bb.hasRemaining())
{
System.out.print(String.format("0x%02X ", new Byte(bb.get())));
}
} catch (CharacterCodingException e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
Test app = new Test();
}
}
---------- END SOURCE ----------
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
java version "1.4.2_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_14-b05)
Java HotSpot(TM) Client VM (build 1.4.2_14-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP Professional Service Pack 2
A DESCRIPTION OF THE PROBLEM :
Shift_JIS encoder can not convert the Unicode character '\uFF0D' which is the fullwidth hyphen (minus) character into Shift-JIS character set (character code 0x817C in Shift-JIS).
When I tried to convert it vice-versa, Shift-JIS character 0x817C was converted into Unicode character \u2212 which is wrong. I think the mapping between Unicode and Shift_JIS has wrong information.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The above code should show the following message.
Unicode Character Data: \uFF0D
Shift_JIS Character Data: 0x81 0x7C
ACTUAL -
Conversion fails due to CharacterCodingException as follows.
Unicode Character Data: \uFF0D
java.nio.charset.UnmappableCharacterException: Input length = 1
at java.nio.charset.CoderResult.throwException(Unknown Source)
at java.nio.charset.CharsetEncoder.encode(Unknown Source)
---------- BEGIN SOURCE ----------
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class Test {
/** Creates a new instance of Test */
public Test() {
char c = '\uFF0D'; // Fullwidth Hyphen-Minus, 0x817C in Shift-JIS
CharsetEncoder ce = Charset.forName("Shift_JIS").newEncoder();
CharBuffer cb = CharBuffer.allocate(1);
ByteBuffer bb;
System.out.println(String.format("Unicode Character Data: \\u%X", new Integer(c)));
cb.put(c);
cb.rewind();
try
{
bb = ce.encode(cb);
System.out.print(ce.charset().displayName() + " Character Data: ");
while (bb.hasRemaining())
{
System.out.print(String.format("0x%02X ", new Byte(bb.get())));
}
} catch (CharacterCodingException e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
Test app = new Test();
}
}
---------- END SOURCE ----------
REPRODUCIBILITY :
This bug can be reproduced always.