author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 47025 | jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/SJIS_0213.java@e78bddc74bf5 |
permissions | -rw-r--r-- |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
1 |
/* |
12431
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
4 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
10 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
15 |
* accompanied this code). |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
16 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
24 |
*/ |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
25 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
26 |
package sun.nio.cs.ext; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
27 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
28 |
import java.nio.ByteBuffer; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
29 |
import java.nio.CharBuffer; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
30 |
import java.nio.charset.Charset; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
31 |
import java.nio.charset.CharsetEncoder; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
32 |
import java.nio.charset.CharsetDecoder; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
33 |
import java.nio.charset.CoderResult; |
12431
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
34 |
import java.security.AccessController; |
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
35 |
import java.security.PrivilegedAction; |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
36 |
import java.util.Arrays; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
37 |
import sun.nio.cs.CharsetMapping; |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
38 |
import sun.nio.cs.*; |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
39 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
40 |
/* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
41 |
* 5 types of entry in SJIS_X_0213/Unicode mapping table |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
42 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
43 |
* (1)Single-Byte |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
44 |
* JIS_X_0213 does not define single-byte character itself, the |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
45 |
* JIS_X_0201 entries are added in for sjis implementation. |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
46 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
47 |
* (2)Double-Byte SJIS <-> BMP Unicode |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
48 |
* ex: 0x8140 U+3000 # IDEOGRAPHIC SPACE |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
49 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
50 |
* (3)Double-Byte SJIS <-> Supplementary |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
51 |
* ex: 0xFCF0 U+2A61A # <cjk> [2000] [Unicode3.1] |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
52 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
53 |
* (4)Double-Byte SJIS <-> Composite |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
54 |
* ex: 0x83F6 U+31F7+309A # [2000] |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
55 |
* |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
56 |
* (5)"Windows-only" special mapping entries |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
57 |
* are handled by MS932_0213. |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
58 |
*/ |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
59 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
60 |
public class SJIS_0213 extends Charset { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
61 |
public SJIS_0213() { |
47025
e78bddc74bf5
8186801: Add regression test to test mapping based charsets (generated at build time)
sherman
parents:
28969
diff
changeset
|
62 |
super("x-SJIS_0213", ExtendedCharsets.aliasesFor("x-SJIS_0213")); |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
63 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
64 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
65 |
public boolean contains(Charset cs) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
66 |
return ((cs.name().equals("US-ASCII")) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
67 |
|| (cs instanceof SJIS) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
68 |
|| (cs instanceof SJIS_0213)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
69 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
70 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
71 |
public CharsetDecoder newDecoder() { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
72 |
return new Decoder(this); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
73 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
74 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
75 |
public CharsetEncoder newEncoder() { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
76 |
return new Encoder(this); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
77 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
78 |
|
12431
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
79 |
static CharsetMapping mapping = AccessController.doPrivileged( |
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
80 |
new PrivilegedAction<CharsetMapping>() { |
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
81 |
public CharsetMapping run() { |
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
82 |
return CharsetMapping.get(SJIS_0213.class.getResourceAsStream("sjis0213.dat")); |
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
83 |
} |
bd2ef6b4190e
7152690: Initialization error with charset SJIS_0213 when security manager is enabled
sherman
parents:
5506
diff
changeset
|
84 |
}); |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
85 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
86 |
protected static class Decoder extends CharsetDecoder { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
87 |
protected static final char UNMAPPABLE = CharsetMapping.UNMAPPABLE_DECODING; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
88 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
89 |
protected Decoder(Charset cs) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
90 |
super(cs, 0.5f, 1.0f); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
91 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
92 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
93 |
private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
94 |
byte[] sa = src.array(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
95 |
int sp = src.arrayOffset() + src.position(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
96 |
int sl = src.arrayOffset() + src.limit(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
97 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
98 |
char[] da = dst.array(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
99 |
int dp = dst.arrayOffset() + dst.position(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
100 |
int dl = dst.arrayOffset() + dst.limit(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
101 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
102 |
try { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
103 |
while (sp < sl) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
104 |
int b1 = sa[sp] & 0xff; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
105 |
char c = decodeSingle(b1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
106 |
int inSize = 1, outSize = 1; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
107 |
char[] cc = null; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
108 |
if (c == UNMAPPABLE) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
109 |
if (sl - sp < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
110 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
111 |
int b2 = sa[sp + 1] & 0xff; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
112 |
c = decodeDouble(b1, b2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
113 |
inSize++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
114 |
if (c == UNMAPPABLE) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
115 |
cc = decodeDoubleEx(b1, b2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
116 |
if (cc == null) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
117 |
if (decodeSingle(b2) == UNMAPPABLE) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
118 |
return CoderResult.unmappableForLength(2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
119 |
else |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
120 |
return CoderResult.unmappableForLength(1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
121 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
122 |
outSize++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
123 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
124 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
125 |
if (dl - dp < outSize) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
126 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
127 |
if (outSize == 2) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
128 |
da[dp++] = cc[0]; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
129 |
da[dp++] = cc[1]; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
130 |
} else { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
131 |
da[dp++] = c; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
132 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
133 |
sp += inSize; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
134 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
135 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
136 |
} finally { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
137 |
src.position(sp - src.arrayOffset()); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
138 |
dst.position(dp - dst.arrayOffset()); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
139 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
140 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
141 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
142 |
private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
143 |
int mark = src.position(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
144 |
try { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
145 |
while (src.hasRemaining()) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
146 |
char[] cc = null; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
147 |
int b1 = src.get() & 0xff; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
148 |
char c = decodeSingle(b1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
149 |
int inSize = 1, outSize = 1; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
150 |
if (c == UNMAPPABLE) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
151 |
if (src.remaining() < 1) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
152 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
153 |
int b2 = src.get() & 0xff; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
154 |
inSize++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
155 |
c = decodeDouble(b1, b2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
156 |
if (c == UNMAPPABLE) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
157 |
cc = decodeDoubleEx(b1, b2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
158 |
if (cc == null) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
159 |
if (decodeSingle(b2) == UNMAPPABLE) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
160 |
return CoderResult.unmappableForLength(2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
161 |
else |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
162 |
return CoderResult.unmappableForLength(1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
163 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
164 |
outSize++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
165 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
166 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
167 |
if (dst.remaining() < outSize) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
168 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
169 |
if (outSize == 2) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
170 |
dst.put(cc[0]); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
171 |
dst.put(cc[1]); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
172 |
} else { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
173 |
dst.put(c); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
174 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
175 |
mark += inSize; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
176 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
177 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
178 |
} finally { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
179 |
src.position(mark); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
180 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
181 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
182 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
183 |
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
184 |
if (src.hasArray() && dst.hasArray()) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
185 |
return decodeArrayLoop(src, dst); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
186 |
else |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
187 |
return decodeBufferLoop(src, dst); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
188 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
189 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
190 |
protected char decodeSingle(int b) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
191 |
return mapping.decodeSingle(b); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
192 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
193 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
194 |
protected char decodeDouble(int b1, int b2) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
195 |
return mapping.decodeDouble(b1, b2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
196 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
197 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
198 |
private char[] cc = new char[2]; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
199 |
private CharsetMapping.Entry comp = new CharsetMapping.Entry(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
200 |
protected char[] decodeDoubleEx(int b1, int b2) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
201 |
int db = (b1 << 8) | b2; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
202 |
if (mapping.decodeSurrogate(db, cc) != null) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
203 |
return cc; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
204 |
comp.bs = db; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
205 |
if (mapping.decodeComposite(comp, cc) != null) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
206 |
return cc; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
207 |
return null; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
208 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
209 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
210 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
211 |
protected static class Encoder extends CharsetEncoder { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
212 |
protected static final int UNMAPPABLE = CharsetMapping.UNMAPPABLE_ENCODING; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
213 |
protected static final int MAX_SINGLEBYTE = 0xff; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
214 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
215 |
protected Encoder(Charset cs) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
216 |
super(cs, 2.0f, 2.0f); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
217 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
218 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
219 |
public boolean canEncode(char c) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
220 |
return (encodeChar(c) != UNMAPPABLE); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
221 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
222 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
223 |
protected int encodeChar(char ch) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
224 |
return mapping.encodeChar(ch); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
225 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
226 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
227 |
protected int encodeSurrogate(char hi, char lo) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
228 |
return mapping.encodeSurrogate(hi, lo); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
229 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
230 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
231 |
private CharsetMapping.Entry comp = new CharsetMapping.Entry(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
232 |
protected int encodeComposite(char base, char cc) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
233 |
comp.cp = base; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
234 |
comp.cp2 = cc; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
235 |
return mapping.encodeComposite(comp); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
236 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
237 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
238 |
protected boolean isCompositeBase(char ch) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
239 |
comp.cp = ch; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
240 |
return mapping.isCompositeBase(comp); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
241 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
242 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
243 |
// Unlike surrogate pair, the base character of a base+cc composite |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
244 |
// itself is a legal codepoint in 0213, if we simply return UNDERFLOW |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
245 |
// when a base candidate is the last input char in the CharBuffer, like |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
246 |
// what we do for the surrogte pair, encoding will fail if this base |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
247 |
// character is indeed the last character of the input char sequence. |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
248 |
// Keep this base candidate in "leftoverBase" so we can flush it out |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
249 |
// at the end of the encoding circle. |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
250 |
char leftoverBase = 0; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
251 |
protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
252 |
char[] sa = src.array(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
253 |
int sp = src.arrayOffset() + src.position(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
254 |
int sl = src.arrayOffset() + src.limit(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
255 |
byte[] da = dst.array(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
256 |
int dp = dst.arrayOffset() + dst.position(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
257 |
int dl = dst.arrayOffset() + dst.limit(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
258 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
259 |
try { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
260 |
while (sp < sl) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
261 |
int db; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
262 |
char c = sa[sp]; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
263 |
if (leftoverBase != 0) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
264 |
boolean isComp = false; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
265 |
db = encodeComposite(leftoverBase, c); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
266 |
if (db == UNMAPPABLE) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
267 |
db = encodeChar(leftoverBase); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
268 |
else |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
269 |
isComp = true; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
270 |
if (dl - dp < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
271 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
272 |
da[dp++] = (byte)(db >> 8); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
273 |
da[dp++] = (byte)db; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
274 |
leftoverBase = 0; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
275 |
if (isComp) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
276 |
sp++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
277 |
continue; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
278 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
279 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
280 |
if (isCompositeBase(c)) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
281 |
leftoverBase = c; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
282 |
} else { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
283 |
db = encodeChar(c); |
688
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
284 |
if (db <= MAX_SINGLEBYTE) { // SingleByte |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
285 |
if (dl <= dp) |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
286 |
return CoderResult.OVERFLOW; |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
287 |
da[dp++] = (byte)db; |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
288 |
} else if (db != UNMAPPABLE) { // DoubleByte |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
289 |
if (dl - dp < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
290 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
291 |
da[dp++] = (byte)(db >> 8); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
292 |
da[dp++] = (byte)db; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
293 |
} else if (Character.isHighSurrogate(c)) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
294 |
if ((sp + 1) == sl) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
295 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
296 |
char c2 = sa[sp + 1]; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
297 |
if (!Character.isLowSurrogate(c2)) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
298 |
return CoderResult.malformedForLength(1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
299 |
db = encodeSurrogate(c, c2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
300 |
if (db == UNMAPPABLE) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
301 |
return CoderResult.unmappableForLength(2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
302 |
if (dl - dp < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
303 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
304 |
da[dp++] = (byte)(db >> 8); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
305 |
da[dp++] = (byte)db; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
306 |
sp++; |
688
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
307 |
} else if (Character.isLowSurrogate(c)) { |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
308 |
return CoderResult.malformedForLength(1); |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
309 |
} else { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
310 |
return CoderResult.unmappableForLength(1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
311 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
312 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
313 |
sp++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
314 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
315 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
316 |
} finally { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
317 |
src.position(sp - src.arrayOffset()); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
318 |
dst.position(dp - dst.arrayOffset()); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
319 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
320 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
321 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
322 |
protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
323 |
int mark = src.position(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
324 |
try { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
325 |
while (src.hasRemaining()) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
326 |
int db; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
327 |
char c = src.get(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
328 |
if (leftoverBase != 0) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
329 |
boolean isComp = false; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
330 |
db = encodeComposite(leftoverBase, c); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
331 |
if (db == UNMAPPABLE) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
332 |
db = encodeChar(leftoverBase); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
333 |
else |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
334 |
isComp = true; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
335 |
if (dst.remaining() < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
336 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
337 |
dst.put((byte)(db >> 8)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
338 |
dst.put((byte)(db)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
339 |
leftoverBase = 0; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
340 |
if (isComp) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
341 |
mark++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
342 |
continue; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
343 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
344 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
345 |
if (isCompositeBase(c)) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
346 |
leftoverBase = c; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
347 |
} else { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
348 |
db = encodeChar(c); |
688
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
349 |
if (db <= MAX_SINGLEBYTE) { // Single-byte |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
350 |
if (dst.remaining() < 1) |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
351 |
return CoderResult.OVERFLOW; |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
352 |
dst.put((byte)db); |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
353 |
} else if (db != UNMAPPABLE) { // DoubleByte |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
354 |
if (dst.remaining() < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
355 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
356 |
dst.put((byte)(db >> 8)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
357 |
dst.put((byte)(db)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
358 |
} else if (Character.isHighSurrogate(c)) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
359 |
if (!src.hasRemaining()) // Surrogates |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
360 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
361 |
char c2 = src.get(); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
362 |
if (!Character.isLowSurrogate(c2)) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
363 |
return CoderResult.malformedForLength(1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
364 |
db = encodeSurrogate(c, c2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
365 |
if (db == UNMAPPABLE) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
366 |
return CoderResult.unmappableForLength(2); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
367 |
if (dst.remaining() < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
368 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
369 |
dst.put((byte)(db >> 8)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
370 |
dst.put((byte)(db)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
371 |
mark++; |
688
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
372 |
} else if (Character.isLowSurrogate(c)) { |
5ebcfc3cebe4
6710199: SJIS_0213 does not handle "unmappable" encoding operation correctly
sherman
parents:
400
diff
changeset
|
373 |
return CoderResult.malformedForLength(1); |
400
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
374 |
} else { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
375 |
return CoderResult.unmappableForLength(1); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
376 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
377 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
378 |
mark++; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
379 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
380 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
381 |
} finally { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
382 |
src.position(mark); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
383 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
384 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
385 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
386 |
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
387 |
if (src.hasArray() && dst.hasArray()) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
388 |
return encodeArrayLoop(src, dst); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
389 |
else |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
390 |
return encodeBufferLoop(src, dst); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
391 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
392 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
393 |
protected CoderResult implFlush(ByteBuffer dst) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
394 |
if (leftoverBase > 0) { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
395 |
if (dst.remaining() < 2) |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
396 |
return CoderResult.OVERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
397 |
int db = encodeChar(leftoverBase); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
398 |
dst.put((byte)(db >> 8)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
399 |
dst.put((byte)(db)); |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
400 |
leftoverBase = 0; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
401 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
402 |
return CoderResult.UNDERFLOW; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
403 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
404 |
|
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
405 |
protected void implReset() { |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
406 |
leftoverBase = 0; |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
407 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
408 |
} |
9f3afee24320
6529796: Support JIS X 0213:2004 in existing JDK versions, especially for Windows Vista
sherman
parents:
diff
changeset
|
409 |
} |