diff --git a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022.java b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022.java index 983d57d2786..7c56c8e5fbc 100644 --- a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022.java +++ b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022.java @@ -395,7 +395,7 @@ abstract class ISO2022 protected final byte maximumDesignatorLength = 4; - protected String SODesig, + protected byte[] SODesig, SS2Desig = null, SS3Desig = null; @@ -426,21 +426,18 @@ abstract class ISO2022 SS3DesDefined = false; } - private int unicodeToNative(char unicode, byte ebyte[]) - { + private int unicodeToNative(char unicode, byte ebyte[]) { int index = 0; - byte tmpByte[]; char convChar[] = {unicode}; byte convByte[] = new byte[4]; int converted; try{ CharBuffer cc = CharBuffer.wrap(convChar); - ByteBuffer bb = ByteBuffer.allocate(4); + ByteBuffer bb = ByteBuffer.wrap(convByte); ISOEncoder.encode(cc, bb, true); bb.flip(); converted = bb.remaining(); - bb.get(convByte,0,converted); } catch(Exception e) { return -1; } @@ -449,9 +446,8 @@ abstract class ISO2022 if (!SODesDefined) { newSODesDefined = true; ebyte[0] = ISO_ESC; - tmpByte = SODesig.getBytes(); - System.arraycopy(tmpByte,0,ebyte,1,tmpByte.length); - index = tmpByte.length+1; + System.arraycopy(SODesig, 0, ebyte, 1, SODesig.length); + index = SODesig.length + 1; } if (!shiftout) { newshiftout = true; @@ -465,9 +461,8 @@ abstract class ISO2022 if (!SS2DesDefined) { newSS2DesDefined = true; ebyte[0] = ISO_ESC; - tmpByte = SS2Desig.getBytes(); - System.arraycopy(tmpByte, 0, ebyte, 1, tmpByte.length); - index = tmpByte.length+1; + System.arraycopy(SS2Desig, 0, ebyte, 1, SS2Desig.length); + index = SS2Desig.length + 1; } ebyte[index++] = ISO_ESC; ebyte[index++] = ISO_SS2_7; @@ -477,9 +472,8 @@ abstract class ISO2022 if(!SS3DesDefined){ newSS3DesDefined = true; ebyte[0] = ISO_ESC; - tmpByte = SS3Desig.getBytes(); - System.arraycopy(tmpByte, 0, ebyte, 1, tmpByte.length); - index = tmpByte.length+1; + System.arraycopy(SS3Desig, 0, ebyte, 1, SS3Desig.length); + index = SS3Desig.length + 1; } ebyte[index++] = ISO_ESC; ebyte[index++] = ISO_SS3_7; @@ -560,7 +554,6 @@ abstract class ISO2022 } } - private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) { diff --git a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java index f9fe0417af0..af623c6c009 100644 --- a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java +++ b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_CNS.java @@ -67,9 +67,9 @@ public class ISO2022_CN_CNS extends ISO2022 implements HistoricallyNamedCharset public Encoder(Charset cs) { super(cs); - SODesig = "$)G"; - SS2Desig = "$*H"; - SS3Desig = "$+I"; + SODesig = new byte[] {'$', ')', 'G' }; + SS2Desig = new byte[] {'$', '*', 'H' }; + SS3Desig = new byte[] {'$', '+', 'I' }; try { Charset cset = Charset.forName("EUC_TW"); // CNS11643 diff --git a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_GB.java b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_GB.java index 1faaa537d7f..aca60b5f255 100644 --- a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_GB.java +++ b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_CN_GB.java @@ -68,7 +68,7 @@ public class ISO2022_CN_GB extends ISO2022 implements HistoricallyNamedCharset public Encoder(Charset cs) { super(cs); - SODesig = "$)A"; + SODesig = new byte[] { '$', ')', 'A'}; try { Charset cset = Charset.forName("EUC_CN"); // GB2312 diff --git a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_KR.java b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_KR.java index 6d96acde6f1..9ee19cbf996 100644 --- a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_KR.java +++ b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022_KR.java @@ -81,11 +81,9 @@ implements HistoricallyNamedCharset private static class Encoder extends ISO2022.Encoder { - public Encoder(Charset cs) - { + public Encoder(Charset cs) { super(cs); - SODesig = "$)C"; - + SODesig = new byte[] {'$', ')', 'C' }; try { ISOEncoder = ksc5601_cs.newEncoder(); } catch (Exception e) { }