115 } 116 } 117 118 protected CoderResult decodeLoop(ByteBuffer src, 119 CharBuffer dst) 120 { 121 if (src.hasArray() && dst.hasArray()) 122 return decodeArrayLoop(src, dst); 123 else 124 return decodeBufferLoop(src, dst); 125 } 126 127 public int decode(byte[] src, int sp, int len, char[] dst) { 128 if (len > dst.length) 129 len = dst.length; 130 int dp = 0; 131 while (dp < len) 132 dst[dp++] = (char)(src[sp++] & 0xff); 133 return dp; 134 } 135 } 136 137 private static class Encoder extends CharsetEncoder 138 implements ArrayEncoder { 139 private Encoder(Charset cs) { 140 super(cs, 1.0f, 1.0f); 141 } 142 143 public boolean canEncode(char c) { 144 return c <= '\u00FF'; 145 } 146 147 public boolean isLegalReplacement(byte[] repl) { 148 return true; // we accept any byte value 149 } 150 151 private final Surrogate.Parser sgp = new Surrogate.Parser(); 152 153 // Method possible replaced with a compiler intrinsic. 154 private static int encodeISOArray(char[] sa, int sp, 280 while (sp < sl) { 281 int ret = encodeISOArray(src, sp, dst, dp, slen); 282 sp = sp + ret; 283 dp = dp + ret; 284 if (ret != slen) { 285 char c = src[sp++]; 286 if (Character.isHighSurrogate(c) && sp < sl && 287 Character.isLowSurrogate(src[sp])) { 288 if (len > dst.length) { 289 sl++; 290 len--; 291 } 292 sp++; 293 } 294 dst[dp++] = repl; 295 slen = Math.min((sl - sp), (dst.length - dp)); 296 } 297 } 298 return dp; 299 } 300 } 301 } | 115 } 116 } 117 118 protected CoderResult decodeLoop(ByteBuffer src, 119 CharBuffer dst) 120 { 121 if (src.hasArray() && dst.hasArray()) 122 return decodeArrayLoop(src, dst); 123 else 124 return decodeBufferLoop(src, dst); 125 } 126 127 public int decode(byte[] src, int sp, int len, char[] dst) { 128 if (len > dst.length) 129 len = dst.length; 130 int dp = 0; 131 while (dp < len) 132 dst[dp++] = (char)(src[sp++] & 0xff); 133 return dp; 134 } 135 136 public boolean isASCIICompatible() { 137 return true; 138 } 139 } 140 141 private static class Encoder extends CharsetEncoder 142 implements ArrayEncoder { 143 private Encoder(Charset cs) { 144 super(cs, 1.0f, 1.0f); 145 } 146 147 public boolean canEncode(char c) { 148 return c <= '\u00FF'; 149 } 150 151 public boolean isLegalReplacement(byte[] repl) { 152 return true; // we accept any byte value 153 } 154 155 private final Surrogate.Parser sgp = new Surrogate.Parser(); 156 157 // Method possible replaced with a compiler intrinsic. 158 private static int encodeISOArray(char[] sa, int sp, 284 while (sp < sl) { 285 int ret = encodeISOArray(src, sp, dst, dp, slen); 286 sp = sp + ret; 287 dp = dp + ret; 288 if (ret != slen) { 289 char c = src[sp++]; 290 if (Character.isHighSurrogate(c) && sp < sl && 291 Character.isLowSurrogate(src[sp])) { 292 if (len > dst.length) { 293 sl++; 294 len--; 295 } 296 sp++; 297 } 298 dst[dp++] = repl; 299 slen = Math.min((sl - sp), (dst.length - dp)); 300 } 301 } 302 return dp; 303 } 304 305 public boolean isASCIICompatible() { 306 return true; 307 } 308 } 309 } |