-
Bug
-
Resolution: Fixed
-
P3
-
6
-
None
-
b26
-
generic
-
generic
decode() of EUC_TW.Decoder and DoubleByteDecoder return CoderResult for unmappable double byte character with wrong "length" value. See test case
below.
import java.nio.charset.*;
import java.nio.*;
public class TestUnmappableForLength {
public static void main(String[] argv) throws CharacterCodingException {
byte[] ba = {(byte)0xa2, (byte)0xff};
//EUC_TW has its own decodeArrayLoop()
testDecode("EUC_TW", ba, 2);
//EUC_CN uses DoubleByteDecoder's decodeArrayLoop()
testDecode("EUC_CN", ba, 2);
}
static void testDecode(String csName, byte[] ba, int expected)
throws CharacterCodingException
{
try {
CoderResult cr = Charset
.forName(csName)
.newDecoder()
.decode(ByteBuffer.wrap(ba), CharBuffer.allocate(4), true);
if (cr.isUnmappable() && cr.length() != expected) {
throw new CharacterCodingException();
}
} catch (IllegalArgumentException x){
x.printStackTrace();
}
}
}
###@###.### 2005-2-09 18:09:10 GMT
below.
import java.nio.charset.*;
import java.nio.*;
public class TestUnmappableForLength {
public static void main(String[] argv) throws CharacterCodingException {
byte[] ba = {(byte)0xa2, (byte)0xff};
//EUC_TW has its own decodeArrayLoop()
testDecode("EUC_TW", ba, 2);
//EUC_CN uses DoubleByteDecoder's decodeArrayLoop()
testDecode("EUC_CN", ba, 2);
}
static void testDecode(String csName, byte[] ba, int expected)
throws CharacterCodingException
{
try {
CoderResult cr = Charset
.forName(csName)
.newDecoder()
.decode(ByteBuffer.wrap(ba), CharBuffer.allocate(4), true);
if (cr.isUnmappable() && cr.length() != expected) {
throw new CharacterCodingException();
}
} catch (IllegalArgumentException x){
x.printStackTrace();
}
}
}
###@###.### 2005-2-09 18:09:10 GMT