12501 break;
12502 case GB18030_FOUR_BYTE:
12503 int offset = (((byte1 - 0x81) * 10 +
12504 (byte2 - 0x30)) * 126 +
12505 byte3 - 0x81) * 10 + byte4 - 0x30;
12506 int hiByte = (offset >>8) & 0xFF;
12507 int lowByte = (offset & 0xFF);
12508
12509 // Mixture of table lookups and algorithmic calculation
12510 // of character values.
12511
12512 // BMP Ranges
12513 if (offset <= 0x4A62)
12514 dst.put(getChar(offset));
12515 else if (offset > 0x4A62 && offset <= 0x82BC)
12516 dst.put((char)(offset + 0x5543));
12517 else if (offset >= 0x82BD && offset <= 0x830D)
12518 dst.put(getChar(offset));
12519 else if (offset >= 0x830D && offset <= 0x93A8)
12520 dst.put((char)(offset + 0x6557));
12521 else if (offset >= 0x93A9 && offset <= 0x99F9)
12522 dst.put(getChar(offset));
12523 // Supplemental UCS planes handled via surrogates
12524 else if (offset >= 0x2E248 && offset < 0x12E248) {
12525 if (offset >= 0x12E248)
12526 return CoderResult.malformedForLength(4);
12527 offset -= 0x1e248;
12528 if ( dst.remaining() < 2)
12529 return CoderResult.OVERFLOW;
12530 // emit high + low surrogate
12531 dst.put((char)((offset - 0x10000) / 0x400 + 0xD800));
12532 dst.put((char)((offset - 0x10000) % 0x400 + 0xDC00));
12533 } else {
12534 return CoderResult.malformedForLength(inputSize);
12535 }
12536 }
12537 mark += inputSize;
12538 }
12539 return CoderResult.UNDERFLOW;
12540 } finally {
12541 src.position(mark);
|
12501 break;
12502 case GB18030_FOUR_BYTE:
12503 int offset = (((byte1 - 0x81) * 10 +
12504 (byte2 - 0x30)) * 126 +
12505 byte3 - 0x81) * 10 + byte4 - 0x30;
12506 int hiByte = (offset >>8) & 0xFF;
12507 int lowByte = (offset & 0xFF);
12508
12509 // Mixture of table lookups and algorithmic calculation
12510 // of character values.
12511
12512 // BMP Ranges
12513 if (offset <= 0x4A62)
12514 dst.put(getChar(offset));
12515 else if (offset > 0x4A62 && offset <= 0x82BC)
12516 dst.put((char)(offset + 0x5543));
12517 else if (offset >= 0x82BD && offset <= 0x830D)
12518 dst.put(getChar(offset));
12519 else if (offset >= 0x830D && offset <= 0x93A8)
12520 dst.put((char)(offset + 0x6557));
12521 else if (offset >= 0x93A9 && offset <= 0x99FB)
12522 dst.put(getChar(offset));
12523 // Supplemental UCS planes handled via surrogates
12524 else if (offset >= 0x2E248 && offset < 0x12E248) {
12525 if (offset >= 0x12E248)
12526 return CoderResult.malformedForLength(4);
12527 offset -= 0x1e248;
12528 if ( dst.remaining() < 2)
12529 return CoderResult.OVERFLOW;
12530 // emit high + low surrogate
12531 dst.put((char)((offset - 0x10000) / 0x400 + 0xD800));
12532 dst.put((char)((offset - 0x10000) % 0x400 + 0xDC00));
12533 } else {
12534 return CoderResult.malformedForLength(inputSize);
12535 }
12536 }
12537 mark += inputSize;
12538 }
12539 return CoderResult.UNDERFLOW;
12540 } finally {
12541 src.position(mark);
|