author | jiangli |
Wed, 27 Sep 2017 17:55:20 -0400 | |
changeset 47548 | 664b9d44db74 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
8795
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
1 |
/* |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
4 |
* |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
8 |
* |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
13 |
* accompanied this code). |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
14 |
* |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
18 |
* |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
21 |
* questions. |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
22 |
*/ |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
23 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
24 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
25 |
/* @test |
44115
bb4e971bf5d4
8176195: Fix misc module dependencies in jdk_core tests
xiaofeya
parents:
8795
diff
changeset
|
26 |
* @bug 6803681 |
bb4e971bf5d4
8176195: Fix misc module dependencies in jdk_core tests
xiaofeya
parents:
8795
diff
changeset
|
27 |
* @summary Test IBM1364 |
bb4e971bf5d4
8176195: Fix misc module dependencies in jdk_core tests
xiaofeya
parents:
8795
diff
changeset
|
28 |
* @modules jdk.charsets |
8795
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
29 |
*/ |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
30 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
31 |
import java.util.Arrays; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
32 |
import java.nio.*; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
33 |
import java.nio.charset.*; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
34 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
35 |
public class TestIBM1364 { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
36 |
private static String c2bNRStr = "\u00AD\u00B7\u2015\u223C\u2299\uFF5E"; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
37 |
private static byte[] c2bNRBytes = new byte[] { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
38 |
(byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
39 |
(byte)0x41, (byte)0x48, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
40 |
(byte)0x41, (byte)0x43, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
41 |
(byte)0x41, (byte)0x49, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
42 |
(byte)0x42, (byte)0xa1, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
43 |
(byte)0x49, (byte)0x6f, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
44 |
(byte)0x49, (byte)0x54, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
45 |
(byte)0x0f }; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
46 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
47 |
// end at SO |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
48 |
private static String mixedStr = "\u008d\u008e\u0020\u3000\u3001\u71ba\u3164\u0088\ue757"; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
49 |
private static byte[] mixedBytes = new byte[] { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
50 |
(byte)0x09, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
51 |
(byte)0x0a, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
52 |
(byte)0x40, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
53 |
(byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
54 |
(byte)0x40, (byte)0x40, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
55 |
(byte)0x41, (byte)0x41, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
56 |
(byte)0x6c, (byte)0x45, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
57 |
(byte)0x84, (byte)0x41, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
58 |
(byte)0x0f, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
59 |
(byte)0x28, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
60 |
(byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
61 |
(byte)0xdd, (byte)0xfd, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
62 |
(byte)0x0f }; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
63 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
64 |
// end at SI |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
65 |
private static String mixedStr2 = "\u008d\u008e\u0020\u3000\u3001\u71ba\u3164\u0088"; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
66 |
private static byte[] mixedBytes2 = new byte[] { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
67 |
(byte)0x09, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
68 |
(byte)0x0a, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
69 |
(byte)0x40, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
70 |
(byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
71 |
(byte)0x40, (byte)0x40, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
72 |
(byte)0x41, (byte)0x41, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
73 |
(byte)0x6c, (byte)0x45, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
74 |
(byte)0x84, (byte)0x41, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
75 |
(byte)0x0f, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
76 |
(byte)0x28 }; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
77 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
78 |
private static byte[][] malformedBytes = { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
79 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
80 |
(byte)0x039, (byte)0x40, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
81 |
(byte)0x0f |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
82 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
83 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
84 |
(byte)0x039, (byte)0x42, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
85 |
(byte)0x0f |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
86 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
87 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
88 |
(byte)0x040, (byte)0x41, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
89 |
(byte)0x0f |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
90 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
91 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
92 |
(byte)0x040, (byte)0xee, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
93 |
(byte)0x0f |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
94 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
95 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
96 |
(byte)0x0ef, (byte)0x30, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
97 |
(byte)0x0f |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
98 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
99 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
100 |
(byte)0x0ff, (byte)0x41, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
101 |
(byte)0x0f |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
102 |
} |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
103 |
}; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
104 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
105 |
private static byte[][] unmappedBytes = { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
106 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
107 |
(byte)0x06c, (byte)0x46, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
108 |
(byte)0x0f, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
109 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
110 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
111 |
(byte)0x078, (byte)0x46, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
112 |
(byte)0x0f, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
113 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
114 |
{ (byte)0x0e, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
115 |
(byte)0x083, (byte)0xfe, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
116 |
(byte)0x0f, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
117 |
}, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
118 |
{ (byte)0xfa }, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
119 |
{ (byte)0xfe }, |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
120 |
}; |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
121 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
122 |
public static void main(String[] args) throws Exception { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
123 |
if (!(Arrays.equals(mixedStr.getBytes("cp1364"), mixedBytes)) || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
124 |
!mixedStr.equals(new String(mixedBytes, "cp1364"))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
125 |
throw new RuntimeException("cp1364 failed on mixed!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
126 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
127 |
if (!(Arrays.equals(mixedStr2.getBytes("cp1364"), mixedBytes2)) || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
128 |
!mixedStr2.equals(new String(mixedBytes2, "cp1364"))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
129 |
throw new RuntimeException("cp1364 failed on mixed!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
130 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
131 |
if (!(Arrays.equals(c2bNRStr.getBytes("cp1364"), c2bNRBytes)) || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
132 |
c2bNRStr.equals(new String(c2bNRBytes, "cp1364"))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
133 |
throw new RuntimeException("cp1364 failed on c2bNR!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
134 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
135 |
ByteBuffer bb = ByteBuffer.allocateDirect(mixedBytes.length); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
136 |
bb.put(mixedBytes).flip(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
137 |
CharBuffer cb = Charset.forName("ibm1364").decode(bb); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
138 |
if (!mixedStr.equals(new String(cb.toString()))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
139 |
throw new RuntimeException("cp1364 failed on direct decod()!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
140 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
141 |
bb = ByteBuffer.allocateDirect(mixedBytes2.length); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
142 |
bb.put(mixedBytes2).flip(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
143 |
cb = Charset.forName("ibm1364").decode(bb); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
144 |
if (!mixedStr2.equals(new String(cb.toString()))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
145 |
throw new RuntimeException("cp1364 failed on direct decod()!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
146 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
147 |
cb = ByteBuffer.allocateDirect(mixedStr.length() * 2).asCharBuffer(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
148 |
cb.put(mixedStr.toCharArray()).flip(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
149 |
bb = Charset.forName("x-ibm1364").encode(cb); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
150 |
if (!(Arrays.equals(Arrays.copyOf(bb.array(), bb.limit()), mixedBytes))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
151 |
throw new RuntimeException("cp1364 failed on direct encode()!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
152 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
153 |
cb = ByteBuffer.allocateDirect(mixedStr2.length() * 2).asCharBuffer(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
154 |
cb.put(mixedStr2.toCharArray()).flip(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
155 |
bb = Charset.forName("x-ibm1364").encode(cb); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
156 |
if (!(Arrays.equals(Arrays.copyOf(bb.array(), bb.limit()), mixedBytes2))) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
157 |
throw new RuntimeException("cp1364 failed on direct encode()!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
158 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
159 |
// malformed |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
160 |
cb = CharBuffer.allocate(1024); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
161 |
CharBuffer cbd = ByteBuffer.allocateDirect(1024).asCharBuffer(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
162 |
CharsetDecoder dec = Charset.forName("x-ibm1364").newDecoder(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
163 |
for (byte[] ba:malformedBytes) { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
164 |
cb.clear(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
165 |
dec.reset(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
166 |
if (!dec.reset().decode(ByteBuffer.wrap(ba), cb, true).isMalformed() || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
167 |
!dec.reset().decode(ByteBuffer.wrap(ba), cbd, true).isMalformed()) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
168 |
throw new RuntimeException("cp1364 failed on decode()/malformed!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
169 |
} |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
170 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
171 |
//unmappable |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
172 |
for (byte[] ba:unmappedBytes) { |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
173 |
cb.clear(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
174 |
dec.reset(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
175 |
if (!dec.reset().decode(ByteBuffer.wrap(ba), cb, true).isUnmappable() || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
176 |
!dec.reset().decode(ByteBuffer.wrap(ba), cbd, true).isUnmappable()) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
177 |
throw new RuntimeException("cp1364 failed on decode()/unmappable!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
178 |
} |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
179 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
180 |
//overflow |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
181 |
cb.limit(mixedStr.length() - 1); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
182 |
cbd.limit(mixedStr.length() - 1); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
183 |
if (!dec.reset().decode(ByteBuffer.wrap(mixedBytes), cb, true).isOverflow() || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
184 |
!dec.reset().decode(ByteBuffer.wrap(mixedBytes), cbd, true).isOverflow()) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
185 |
throw new RuntimeException("cp1364 failed on decode()/overflow!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
186 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
187 |
CharsetEncoder enc = Charset.forName("x-ibm1364").newEncoder(); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
188 |
// last "0x0f" is from flush() |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
189 |
bb = ByteBuffer.allocate(mixedBytes.length - 2); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
190 |
ByteBuffer bbd = ByteBuffer.allocateDirect(mixedBytes.length - 2); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
191 |
if (!enc.reset() |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
192 |
.encode(CharBuffer.wrap(mixedStr.toCharArray()), bb, true) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
193 |
.isOverflow() || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
194 |
!enc.reset() |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
195 |
.encode(CharBuffer.wrap(mixedStr.toCharArray()), bbd, true) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
196 |
.isOverflow()) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
197 |
throw new RuntimeException("cp1364 failed on encode()/overflow!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
198 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
199 |
// flush() overflow |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
200 |
bb = ByteBuffer.allocate(mixedBytes.length - 1); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
201 |
bbd = ByteBuffer.allocateDirect(mixedBytes.length - 1); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
202 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
203 |
enc.reset().encode(CharBuffer.wrap(mixedStr.toCharArray()), bb, true); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
204 |
enc.reset().encode(CharBuffer.wrap(mixedStr.toCharArray()), bbd, true); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
205 |
|
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
206 |
if (!enc.flush(bb).isOverflow() || |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
207 |
!enc.flush(bbd).isOverflow()) |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
208 |
throw new RuntimeException("cp1364 failed on encode()/flush()/overflow!"); |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
209 |
} |
d235a77ef918
6803681: RFE: Need new codeset converter for IBM Cp1364
sherman
parents:
diff
changeset
|
210 |
} |