-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0, 1.2.2
-
005
-
generic, x86
-
generic, windows_nt
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2025509 | 1.3.0 | Jon Ellis | P4 | Resolved | Fixed | kestrel |
Name: clC74495 Date: 02/27/99
1. We can't use SQL statement that contains Japanese characters,
Because jdbc.odbc.JdbcOdbcObject.CharsToBytes loses converted
bytes for Japanese.
1a) Convert Japanese (MS932) char-array to byte-array by
jdbc.odbc.JdbcOdbcObject.CharsToBytes.
1b) On the output (byte-array), we'll lose trailing few bytes that
depends on number of Double Byte Characters in input (char-array).
2. Following is test program.
=== cut from here ===
// foo.java
import java.io.*;
import sun.jdbc.odbc.*;
public class foo {
private static void dump(byte bytes[]) {
char hex[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
};
for (int i = 0; i < bytes.length; ++i) {
if ((i & 0xf) == 0) {
System.out.println();
}
int hi = (((int) bytes[i]) >> 4) & 0xf;
int lo = ((int) bytes[i]) & 0xf;
System.out.print(" " + hex[hi] + hex[lo]);
}
System.out.println();
}
public static void main(String args[]) {
String string = "select \u30d5\u30a3\u30fc\u30eb\u30c92 from Num12345";
char chars[] = string.toCharArray();
JdbcOdbcObject jdbcOdbcObject = new JdbcOdbcObject();
try {
byte bytes[];
bytes = jdbcOdbcObject.CharsToBytes("MS932", chars);
dump(bytes);
} catch (UnsupportedEncodingException e) {
System.err.println("UnsupportedEncodingException = " + e);
System.exit(1);
}
System.exit(0);
}
}
=== end of cut ===
3. We'll lose trailing 4 bytes on execution of foo.class.
=== actual result of foo.class ===
73 65 6c 65 63 74 20 83 74 83 42 81 5b 83 8b 83
68 32 20 66 72 6f 6d 20 4e 75 6d 31
=== end of result ===
=== expected result of foo.class ===
73 65 6c 65 63 74 20 83 74 83 42 81 5b 83 8b 83
68 32 20 66 72 6f 6d 20 4e 75 6d 31 32 33 34 35
=== end of result ===
4. Nothing.
5. I used MS932 as test case of encoding. But the problem will occurr on any Double Byte Character encodings.
(Review ID: 54766)
======================================================================
- backported by
-
JDK-2025509 sun.jdbc.odbc.JdbcOdbcObject.CharsToBytes lose converted bytes for Japanese
- Resolved
- duplicates
-
JDK-4301314 An SQL string that contains a Kanji character is truncated at illegal positoin.
- Closed