src/jdk.charsets/share/classes/sun/nio/cs/ext/ISO2022.java

Print this page

        

@@ -393,11 +393,11 @@
         public static final byte PLANE3 = (byte)0xA3;
         private final byte MSB = (byte)0x80;
 
         protected final byte maximumDesignatorLength = 4;
 
-        protected String SODesig,
+        protected byte[] SODesig,
                          SS2Desig = null,
                          SS3Desig = null;
 
         protected CharsetEncoder ISOEncoder;
 

@@ -424,36 +424,32 @@
             SODesDefined = false;
             SS2DesDefined = false;
             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;
             }
 
             if (converted == 2) {
                 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;
                     ebyte[index++] = ISO_SO;
                 }

@@ -463,25 +459,23 @@
                 if(convByte[0] == SS2) {
                     if (convByte[1] == PLANE2) {
                         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;
                         ebyte[index++] = (byte)(convByte[2] & 0x7f);
                         ebyte[index++] = (byte)(convByte[3] & 0x7f);
                     } else if (convByte[1] == PLANE3) {
                         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;
                         ebyte[index++] = (byte)(convByte[2] & 0x7f);
                         ebyte[index++] = (byte)(convByte[3] & 0x7f);

@@ -558,11 +552,10 @@
                 src.position(sp - src.arrayOffset());
                 dst.position(dp - dst.arrayOffset());
              }
         }
 
-
         private CoderResult encodeBufferLoop(CharBuffer src,
                                              ByteBuffer dst)
         {
             int outputSize = 0;
             byte[]  outputByte = new byte[8];