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

Print this page

        

@@ -608,10 +608,15 @@
                 return encodeArrayLoop(src, dst);
             else
                 return encodeBufferLoop(src, dst);
         }
 
+        protected 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;
             int dl = dst.length;
             while (sp < sl) {

@@ -620,11 +625,10 @@
                 if (bb == UNMAPPABLE_ENCODING) {
                     if (Character.isHighSurrogate(c) && sp < sl &&
                         Character.isLowSurrogate(src[sp])) {
                         sp++;
                     }
-                    byte[] repl = replacement();
                     dst[dp++] = repl[0];
                     if (repl.length > 1)
                         dst[dp++] = repl[1];
                     continue;
                 } //else

@@ -875,11 +879,10 @@
                 if (bb == UNMAPPABLE_ENCODING) {
                     if (Character.isHighSurrogate(c) && sp < sl &&
                         Character.isLowSurrogate(src[sp])) {
                         sp++;
                     }
-                    byte[] repl = replacement();
                     dst[dp++] = repl[0];
                     if (repl.length > 1)
                         dst[dp++] = repl[1];
                     continue;
                 } //else