* See specification GBT 18284-2000 */
| 56 | * See specification GBT 18284-2000 |
| 57 | */ |
| 58 | static void DecodeHanziSegment(BitSource& bits, int count, Content& result) |
| 59 | { |
| 60 | // Each character will require 2 bytes, decode as GB2312 |
| 61 | // There is no ECI value for GB2312, use GB18030 which is a superset |
| 62 | result.switchEncoding(CharacterSet::GB18030); |
| 63 | result.reserve(2 * count); |
| 64 | |
| 65 | while (count > 0) { |
| 66 | // Each 13 bits encodes a 2-byte character |
| 67 | int twoBytes = bits.readBits(13); |
| 68 | int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060); |
| 69 | if (assembledTwoBytes < 0x00A00) { |
| 70 | // In the 0xA1A1 to 0xAAFE range |
| 71 | assembledTwoBytes += 0x0A1A1; |
| 72 | } else { |
| 73 | // In the 0xB0A1 to 0xFAFE range |
| 74 | assembledTwoBytes += 0x0A6A1; |
| 75 | } |
| 76 | result += narrow_cast<uint8_t>((assembledTwoBytes >> 8) & 0xFF); |
| 77 | result += narrow_cast<uint8_t>(assembledTwoBytes & 0xFF); |
| 78 | count--; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | static void DecodeKanjiSegment(BitSource& bits, int count, Content& result) |
| 83 | { |
no test coverage detected