In Java GB18030 charset, decode impl have this code
// Either 2 or 4 byte sequence follows
if ( sl - sp < 2 )
return CoderResult.UNDERFLOW;
byte2 = sa[sp + 1] & 0xFF;
inputSize = 2;
if (byte2 < 0x30)
return CoderResult.malformedForLength(1);
this code position is in GB18030.Decode#decodeArrayLoop
, so when the char is double byte or four byte to show, I don’t know why the second byte(namely byte2) if malformed will throw malformed exception with 1 not 2.
Maybe it should be throw exception with 2?
New contributor
tzzz z is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.