MCPcopy Create free account
hub / github.com/devilsen/CZXing / DecodeHanziSegment

Function DecodeHanziSegment

czxing/src/main/cpp/zxing/src/qrcode/QRDecoder.cpp:58–80  ·  view source on GitHub ↗

* See specification GBT 18284-2000 */

Source from the content-addressed store, hash-verified

56* See specification GBT 18284-2000
57*/
58static 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
82static void DecodeKanjiSegment(BitSource& bits, int count, Content& result)
83{

Callers 1

Calls 3

switchEncodingMethod · 0.45
reserveMethod · 0.45
readBitsMethod · 0.45

Tested by

no test coverage detected