Fix Kanji decoding.
Before this patch, Kanji decoding was broken.
This commit is contained in:
parent
3c31aa0987
commit
e16c02e226
1 changed files with 10 additions and 4 deletions
14
lib/decode.c
14
lib/decode.c
|
@ -790,12 +790,18 @@ static quirc_decode_error_t decode_kanji(struct quirc_data *data,
|
|||
|
||||
for (i = 0; i < count; i++) {
|
||||
int d = take_bits(ds, 13);
|
||||
int msB = d / 0xc0;
|
||||
int lsB = d % 0xc0;
|
||||
int intermediate = (msB << 8) | lsB;
|
||||
uint16_t sjw;
|
||||
|
||||
if (d + 0x8140 >= 0x9ffc)
|
||||
sjw = d + 0x8140;
|
||||
else
|
||||
sjw = d + 0xc140;
|
||||
if (intermediate + 0x8140 <= 0x9ffc) {
|
||||
/* bytes are in the range 0x8140 to 0x9FFC */
|
||||
sjw = intermediate + 0x8140;
|
||||
} else {
|
||||
/* bytes are in the range 0x8140 to 0x9FFC */
|
||||
sjw = intermediate + 0xc140;
|
||||
}
|
||||
|
||||
data->payload[data->payload_len++] = sjw >> 8;
|
||||
data->payload[data->payload_len++] = sjw & 0xff;
|
||||
|
|
Loading…
Reference in a new issue