src/java.base/share/classes/sun/nio/cs/HKSCS.java
Print this page
@@ -51,11 +51,11 @@
char[][] b2cBmp, char[][] b2cSupp)
{
// super(cs, 0.5f, 1.0f);
// need to extends DoubleByte.Decoder so the
// sun.io can use it. this implementation
- super(cs, 0.5f, 1.0f, null, null, 0, 0);
+ super(cs, 0.5f, 1.0f, null, null, 0, 0, true);
this.big5Dec = big5Dec;
this.b2cBmp = b2cBmp;
this.b2cSupp = b2cSupp;
}
@@ -237,11 +237,11 @@
protected Encoder(Charset cs,
DoubleByte.Encoder big5Enc,
char[][] c2bBmp,
char[][] c2bSupp)
{
- super(cs, null, null);
+ super(cs, null, null, true);
this.big5Enc = big5Enc;
this.c2bBmp = c2bBmp;
this.c2bSupp = c2bSupp;
}
@@ -387,10 +387,37 @@
}
}
return dp;
}
+ public int encodeFromUTF16(byte[] src, int sp, int len, byte[] dst) {
+ int dp = 0;
+ int sl = sp + len;
+ int dl = dst.length;
+ while (sp < sl) {
+ char c = StringUTF16.getChar(src, sp++);
+ int bb = encodeChar(c);
+ if (bb == UNMAPPABLE_ENCODING) {
+ if (!Character.isHighSurrogate(c) || sp == sl ||
+ !Character.isLowSurrogate(StringUTF16.getChar(src,sp)) ||
+ (bb = encodeSupp(Character.toCodePoint(c, StringUTF16.getChar(src, sp++))))
+ == UNMAPPABLE_ENCODING) {
+ dst[dp++] = repl[0];
+ if (repl.length > 1)
+ dst[dp++] = repl[1];
+ continue;
+ }
+ }
+ if (bb > MAX_SINGLEBYTE) { // DoubleByte
+ dst[dp++] = (byte)(bb >> 8);
+ dst[dp++] = (byte)bb;
+ } else { // SingleByte
+ dst[dp++] = (byte)bb;
+ }
+ }
+ return dp;
+ }
static char[] C2B_UNMAPPABLE = new char[0x100];
static {
Arrays.fill(C2B_UNMAPPABLE, (char)UNMAPPABLE_ENCODING);
}