From 8fcde380f809976ea5217799360d04368fa15961 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Wed, 20 Jun 2018 23:07:48 +0100 Subject: [PATCH] Increase character count for percentages in alphanumeric mode --- backend/qr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/qr.c b/backend/qr.c index f122af15..623e8ed5 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -153,6 +153,7 @@ static void qr_binary(int datastream[], const int version, const int target_binl char padbits; int current_binlen, current_bytes; int toggle, percent; + int percent_count; #ifndef _MSC_VER char binary[est_binlen + 12]; @@ -268,11 +269,18 @@ static void qr_binary(int datastream[], const int version, const int target_binl /* Mode indicator */ strcat(binary, "0010"); + percent_count = 0; + for (i = 0; i < short_data_block_length; i++) { + if (gs1 && (jisdata[position + i] == '%')) { + percent_count++; + } + } + /* Character count indicator */ - bin_append(short_data_block_length, tribus(version, 9, 11, 13), binary); + bin_append(short_data_block_length + percent_count, tribus(version, 9, 11, 13), binary); if (debug) { - printf("Alpha block (length %d)\n\t", short_data_block_length); + printf("Alpha block (length %d)\n\t", short_data_block_length + percent_count); } /* Character representation */