8166339: Code conversion working behavior was changed for x-IBM834
Reviewed-by: coffeys
This commit is contained in:
parent
967599181a
commit
46d5554295
@ -236,10 +236,8 @@ public class DoubleByte {
|
||||
int b2 = src[sp++] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte
|
||||
b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte
|
||||
decodeSingle(b2) != UNMAPPABLE_DECODING) {
|
||||
sp--;
|
||||
if (crMalformedOrUnmappable(b1, b2).length() == 1) {
|
||||
sp--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,6 +470,13 @@ public class DoubleByte {
|
||||
b2cSB_UNMAPPABLE = new char[0x100];
|
||||
Arrays.fill(b2cSB_UNMAPPABLE, UNMAPPABLE_DECODING);
|
||||
}
|
||||
|
||||
// always returns unmappableForLenth(2) for doublebyte_only
|
||||
@Override
|
||||
protected CoderResult crMalformedOrUnmappable(int b1, int b2) {
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
|
||||
public Decoder_DBCSONLY(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max,
|
||||
boolean isASCIICompatible) {
|
||||
super(cs, 0.5f, 1.0f, b2c, b2cSB_UNMAPPABLE, b2Min, b2Max, isASCIICompatible);
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 6379808
|
||||
* @bug 6379808 8166339
|
||||
* @summary Check all Cp933 SBCS characters are not supported in Cp834
|
||||
* @modules jdk.charsets
|
||||
*/
|
||||
@ -62,17 +62,34 @@ public class TestCp834_SBCS {
|
||||
if ((c = cb.get()) != '\ufffd') {
|
||||
// OK, this is a SBCS character in Cp933
|
||||
if (dec834.decode(ByteBuffer.wrap(ba)).get() != '\ufffd')
|
||||
throw new Exception("SBCS is supported in IBM834 decoder");
|
||||
throw new RuntimeException("SBCS is supported in IBM834 decoder");
|
||||
|
||||
if (enc834.canEncode(c))
|
||||
throw new Exception("SBCS can be encoded in IBM834 encoder");
|
||||
throw new RuntimeException("SBCS can be encoded in IBM834 encoder");
|
||||
|
||||
ca[0] = c;
|
||||
ByteBuffer bb = enc834.encode(CharBuffer.wrap(ca));
|
||||
if (bb.get() != (byte)0xfe || bb.get() != (byte)0xfe)
|
||||
throw new Exception("SBCS is supported in IBM834 encoder");
|
||||
throw new RuntimeException("SBCS is supported in IBM834 encoder");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 8166339: cp834 should handle unmappable bytes as dobule-byte pair.
|
||||
if (! new String("\ufffd".getBytes("cp834"), "cp834").equals("\ufffd")) {
|
||||
throw new RuntimeException("u+fffd roundtrip failed");
|
||||
}
|
||||
|
||||
if (! new String("a".getBytes("cp834"), "cp834").equals("\ufffd") ||
|
||||
! new String(new byte[] { 0x41, 0x40}, "cp834").equals("\ufffd")) {
|
||||
throw new RuntimeException("decoding unmappable don't return u+fffd");
|
||||
}
|
||||
|
||||
CoderResult cr = Charset.forName("Cp834").newDecoder().decode(
|
||||
ByteBuffer.wrap(new byte[] { 0x41, 0x40}), CharBuffer.wrap(new char[2]), true);
|
||||
if (cr.isError() && cr.length() != 2) {
|
||||
throw new RuntimeException("decoding unmappable don't return unmmappable(2)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user