532 if (b1 > 0xf4 || 533 sp < sl && isMalformed4_2(b1, sa[sp] & 0xff)) { 534 da[dp++] = replacement().charAt(0); 535 continue; 536 } 537 sp++; 538 if (sp < sl && isMalformed4_3(sa[sp])) { 539 da[dp++] = replacement().charAt(0); 540 continue; 541 } 542 da[dp++] = replacement().charAt(0); 543 return dp; 544 } else { 545 if (malformedInputAction() != CodingErrorAction.REPLACE) 546 return -1; 547 da[dp++] = replacement().charAt(0); 548 } 549 } 550 return dp; 551 } 552 } 553 554 private static final class Encoder extends CharsetEncoder 555 implements ArrayEncoder { 556 557 private Encoder(Charset cs) { 558 super(cs, 1.1f, 3.0f); 559 } 560 561 public boolean canEncode(char c) { 562 return !Character.isSurrogate(c); 563 } 564 565 public boolean isLegalReplacement(byte[] repl) { 566 return ((repl.length == 1 && repl[0] >= 0) || 567 super.isLegalReplacement(repl)); 568 } 569 570 private static CoderResult overflow(CharBuffer src, int sp, 571 ByteBuffer dst, int dp) { 725 if (uc < 0) { 726 if (malformedInputAction() != CodingErrorAction.REPLACE) 727 return -1; 728 da[dp++] = repl; 729 } else { 730 da[dp++] = (byte)(0xf0 | ((uc >> 18))); 731 da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); 732 da[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); 733 da[dp++] = (byte)(0x80 | (uc & 0x3f)); 734 sp++; // 2 chars 735 } 736 } else { 737 // 3 bytes, 16 bits 738 da[dp++] = (byte)(0xe0 | ((c >> 12))); 739 da[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); 740 da[dp++] = (byte)(0x80 | (c & 0x3f)); 741 } 742 } 743 return dp; 744 } 745 } 746 } | 532 if (b1 > 0xf4 || 533 sp < sl && isMalformed4_2(b1, sa[sp] & 0xff)) { 534 da[dp++] = replacement().charAt(0); 535 continue; 536 } 537 sp++; 538 if (sp < sl && isMalformed4_3(sa[sp])) { 539 da[dp++] = replacement().charAt(0); 540 continue; 541 } 542 da[dp++] = replacement().charAt(0); 543 return dp; 544 } else { 545 if (malformedInputAction() != CodingErrorAction.REPLACE) 546 return -1; 547 da[dp++] = replacement().charAt(0); 548 } 549 } 550 return dp; 551 } 552 553 public boolean isASCIICompatible() { 554 return true; 555 } 556 } 557 558 private static final class Encoder extends CharsetEncoder 559 implements ArrayEncoder { 560 561 private Encoder(Charset cs) { 562 super(cs, 1.1f, 3.0f); 563 } 564 565 public boolean canEncode(char c) { 566 return !Character.isSurrogate(c); 567 } 568 569 public boolean isLegalReplacement(byte[] repl) { 570 return ((repl.length == 1 && repl[0] >= 0) || 571 super.isLegalReplacement(repl)); 572 } 573 574 private static CoderResult overflow(CharBuffer src, int sp, 575 ByteBuffer dst, int dp) { 729 if (uc < 0) { 730 if (malformedInputAction() != CodingErrorAction.REPLACE) 731 return -1; 732 da[dp++] = repl; 733 } else { 734 da[dp++] = (byte)(0xf0 | ((uc >> 18))); 735 da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); 736 da[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); 737 da[dp++] = (byte)(0x80 | (uc & 0x3f)); 738 sp++; // 2 chars 739 } 740 } else { 741 // 3 bytes, 16 bits 742 da[dp++] = (byte)(0xe0 | ((c >> 12))); 743 da[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); 744 da[dp++] = (byte)(0x80 | (c & 0x3f)); 745 } 746 } 747 return dp; 748 } 749 750 public boolean isASCIICompatible() { 751 return true; 752 } 753 } 754 } |