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 bytes 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 thrown exception with 2 ?