[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/23637] New: Incorrect conversion of UTF-16 decoder
From: |
freebeans at xqb dot biglobe dot ne dot jp |
Subject: |
[Bug classpath/23637] New: Incorrect conversion of UTF-16 decoder |
Date: |
30 Aug 2005 14:35:15 -0000 |
UTF-16 encoder (gnu.java.nio.charset.UTF_16Decoder) could not decode correctly.
Example:
public class EncodingTest {
static final String JAPANESE_HIRAGANA_LETTER_RA = "\u3089";
public static void main(String[] args) throws Exception {
String s1 = JAPANESE_HIRAGANA_LETTER_RA;
byte[] data = s1.getBytes("UTF-16LE");
String s2 = new String(data, "UTF-16LE");
if (s1.equals(s2)) {
System.out.println("OK");
} else {
System.out.println("NG");
}
}
---
Example shows "NG".
UTF_16Decoder line 108:
---
108: char c = byteOrder == BIG_ENDIAN ? (char) ((b1 << 8) | b2)
109: : (char) ((b2 << 8) | b1);
---
But I think that the following codes are correct.
---
108: char c = byteOrder == BIG_ENDIAN ? (char) ((b1 << 8) | (b2 & 0xff))
109: : (char) ((b2 << 8) | (b1 &
0xff));
---
Thank you.
--
Summary: Incorrect conversion of UTF-16 decoder
Product: classpath
Version: 0.17
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: freebeans at xqb dot biglobe dot ne dot jp
CC: bug-classpath at gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23637
- [Bug classpath/23637] New: Incorrect conversion of UTF-16 decoder,
freebeans at xqb dot biglobe dot ne dot jp <=