src/share/classes/sun/nio/cs/ext/HKSCS.java

Print this page

        

@@ -354,10 +354,15 @@
                 return encodeArrayLoop(src, dst);
             else
                 return encodeBufferLoop(src, dst);
         }
 
+        private byte[] repl = replacement();
+        protected void implReplaceWith(byte[] newReplacement) {
+            repl = newReplacement;
+        }
+
         public int encode(char[] src, int sp, int len, byte[] dst) {
             int dp = 0;
             int sl = sp + len;
             while (sp < sl) {
                 char c = src[sp++];

@@ -365,11 +370,10 @@
                 if (bb == UNMAPPABLE_ENCODING) {
                     if (!Character.isHighSurrogate(c) || sp == sl ||
                         !Character.isLowSurrogate(src[sp]) ||
                         (bb = encodeSupp(Character.toCodePoint(c, src[sp++])))
                         == UNMAPPABLE_ENCODING) {
-                        byte[] repl = replacement();
                         dst[dp++] = repl[0];
                         if (repl.length > 1)
                             dst[dp++] = repl[1];
                         continue;
                     }