diff --git a/src/share/classes/sun/nio/cs/ext/HKSCS.java b/src/share/classes/sun/nio/cs/ext/HKSCS.java index 07be74d9581c99d0d6418683c8c2658695344377..1e900938ea6629b353a9661d4483d88cd17a9633 100644 --- a/src/share/classes/sun/nio/cs/ext/HKSCS.java +++ b/src/share/classes/sun/nio/cs/ext/HKSCS.java @@ -377,7 +377,6 @@ public class HKSCS { dst[dp++] = repl[1]; continue; } - sp++; } if (bb > MAX_SINGLEBYTE) { // DoubleByte dst[dp++] = (byte)(bb >> 8); diff --git a/test/sun/nio/cs/TestStringCoding.java b/test/sun/nio/cs/TestStringCoding.java index aaee1bcd2e3d88c2058e892f5747cd3757f617d5..4bff4cfcd61fe83213db90bfc7f39ffa34370006 100644 --- a/test/sun/nio/cs/TestStringCoding.java +++ b/test/sun/nio/cs/TestStringCoding.java @@ -22,7 +22,7 @@ */ /* @test - @bug 6636323 6636319 7040220 7096080 7183053 + @bug 6636323 6636319 7040220 7096080 7183053 8080248 @summary Test if StringCoding and NIO result have the same de/encoding result * @run main/othervm/timeout=2000 TestStringCoding */ @@ -199,6 +199,17 @@ public class TestStringCoding { */ } + //encode mappable surrogates for hkscs + if (cs.name().equals("Big5-HKSCS") || cs.name().equals("x-MS950-HKSCS")) { + String str = "ab\uD840\uDD0Ccd"; + byte[] expected = new byte[] {(byte)'a', (byte)'b', + (byte)0x88, (byte)0x45, (byte)'c', (byte)'d' }; + if (!Arrays.equals(str.getBytes(cs.name()), expected) || + !Arrays.equals(str.getBytes(cs), expected)) { + throw new RuntimeException("encode(surrogates) failed -> " + + cs.name()); + } + } } static class PermissiveSecurityManger extends SecurityManager {