1
0
Fork 0
mirror of https://github.com/zxing/zxing.git synced 2025-03-05 20:48:51 -08:00

Fix QR-code hanzi segment decoder ()

* Fix QR-code hanzi segment decoder

* remove unicode character
This commit is contained in:
MakKi (makki_d) 2018-06-21 02:52:44 +09:00 committed by Sean Owen
parent 15b09aeda5
commit 0cf3b9be71
2 changed files with 14 additions and 1 deletions
core/src
main/java/com/google/zxing/qrcode/decoder
test/java/com/google/zxing/qrcode/decoder

View file

@ -160,7 +160,7 @@ final class DecodedBitStreamParser {
// Each 13 bits encodes a 2-byte character
int twoBytes = bits.readBits(13);
int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
if (assembledTwoBytes < 0x003BF) {
if (assembledTwoBytes < 0x00A00) {
// In the 0xA1A1 to 0xAAFE range
assembledTwoBytes += 0x0A1A1;
} else {

View file

@ -81,6 +81,19 @@ public final class DecodedBitStreamParserTestCase extends Assert {
assertEquals("\u963f", result);
}
@Test
public void testHanziLevel1() throws Exception {
BitSourceBuilder builder = new BitSourceBuilder();
builder.write(0x0D, 4); // Hanzi mode
builder.write(0x01, 4); // Subset 1 = GB2312 encoding
builder.write(0x01, 8); // 1 characters
// A5A2 (U+30A2) => A5A2 - A1A1 = 401, 4*60 + 01 = 0181
builder.write(0x0181, 13);
String result = DecodedBitStreamParser.decode(builder.toByteArray(),
Version.getVersionForNumber(1), null, null).getText();
assertEquals("\u30a2", result);
}
// TODO definitely need more tests here
}