mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Fix QR-code hanzi segment decoder (#1033)
* Fix QR-code hanzi segment decoder * remove unicode character
This commit is contained in:
parent
15b09aeda5
commit
0cf3b9be71
|
@ -160,7 +160,7 @@ final class DecodedBitStreamParser {
|
||||||
// Each 13 bits encodes a 2-byte character
|
// Each 13 bits encodes a 2-byte character
|
||||||
int twoBytes = bits.readBits(13);
|
int twoBytes = bits.readBits(13);
|
||||||
int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
|
int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
|
||||||
if (assembledTwoBytes < 0x003BF) {
|
if (assembledTwoBytes < 0x00A00) {
|
||||||
// In the 0xA1A1 to 0xAAFE range
|
// In the 0xA1A1 to 0xAAFE range
|
||||||
assembledTwoBytes += 0x0A1A1;
|
assembledTwoBytes += 0x0A1A1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -81,6 +81,19 @@ public final class DecodedBitStreamParserTestCase extends Assert {
|
||||||
assertEquals("\u963f", result);
|
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
|
// TODO definitely need more tests here
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue