heuer / segno

Python QR Code and Micro QR Code encoder
https://pypi.org/project/segno/
BSD 3-Clause "New" or "Revised" License
631 stars 54 forks source link

Limitations on the maximum number of characters that can be entered #115

Open rabbittyu opened 2 years ago

rabbittyu commented 2 years ago

@heuer

What is the maximum number of characters that can be added using segno's Structured Append?

I am facing the phenomenon that QR codes can be output but cannot be read.

The source code and the string I put in is shown below.

read correctly

import segno

qr_txt='1l2l3l4l5l6l7l8l9l10l11l12l13l14l15l16l17l18l19l20l21l22l23l24l25l26l27l28l29l30l31l32l33l34l35l36l37l38l39l40l41l42l43l44l45l46l47l48l49l50l51l52l53l54l55l56l57l58l59l60l61l62l63l64l65l66l67l68l69l70l71l72l73l74l75l76l77l78l79l80l81l82l83l84l85l86l87l88l89l90l91l92l93l94l95l96l97l98l99l100l101l102l103l104l105l106l107l108l109l110l111l112l113l114l115l116l117l118l119l120l121l122l123l124l125l126l127l128l129l130l131l132l133l134l135l136l137l138l139l140l141l142l143l144l145l146l147l148l149l150l151l152l153l154l155l156l157l158lf'
qr_txt = qr_txt.encode('utf-8')

qrcode_seq = segno.make_sequence(qr_txt, version=5, mode='byte', boost_error=False, error='L') 

(Character before decoding) b'1l2l3l4l5l6l7l8l9l10l11l12l13l14l15l16l17l18l19l20l21l22l23l24l25l26l27l28l29l30l31l32l33l34l35l36l37l38\x0039l40l41l42l43l44l45l46l47l48l49l50l51l52l53l54l55l56l57l58l59l60l61l62l63l64l65l66l67l68l69l70l71l72l73\x0074l75l76l77l78l79l80l81l82l83l84l85l86l87l88l89l90l91l92l93l94l95l96l97l98l99l100l101l102l103l104l105l10\x00l107l108l109l110l111l112l113l114l115l116l117l118l119l120l121l122l123l124l125l126l127l128l129l130l131l132\x00133l134l135l136l137l138l139l140l141l142l143l144l145l146l147l148l149l150l151l152l153l154l155l156l157l158l\x00\r'

The last character disappeared

import segno

qr_txt='1l2l3l4l5l6l7l8l9l10l11l12l13l14l15l16l17l18l19l20l21l22l23l24l25l26l27l28l29l30l31l32l33l34l35l36l37l38l39l40l41l42l43l44l45l46l47l48l49l50l51l52l53l54l55l56l57l58l59l60l61l62l63l64l65l66l67l68l69l70l71l72l73l74l75l76l77l78l79l80l81l82l83l84l85l86l87l88l89l90l91l92l93l94l95l96l97l98l99l100l101l102l103l104l105l106l107l108l109l110l111l112l113l114l115l116l117l118l119l120l121l122l123l124l125l126l127l128l129l130l131l132l133l134l135l136l137l138l139l140l141l142l143l144l145l146l147l148l149l150l151l152l153l154l155l156l157l158l'
qr_txt = qr_txt.encode('utf-8')

qrcode_seq = segno.make_sequence(qr_txt, version=5, mode='byte', boost_error=False, error='L') 

(Character before decoding) b'1l2l3l4l5l6l7l8l9l10l11l12l13l14l15l16l17l18l19l20l21l22l23l24l25l26l27l28l29l30l31l32l33l34l35l36l37l38\x0039l40l41l42l43l44l45l46l47l48l49l50l51l52l53l54l55l56l57l58l59l60l61l62l63l64l65l66l67l68l69l70l71l72l73\x0074l75l76l77l78l79l80l81l82l83l84l85l86l87l88l89l90l91l92l93l94l95l96l97l98l99l100l101l102l103l104l105l10\x00l107l108l109l110l111l112l113l114l115l116l117l118l119l120l121l122l123l124l125l126l127l128l129l130l131l132\x00133l134l135l136l137l138l139l140l141l142l143l144l145l146l147l148l149l150l151l152l153l154l155l156l157l158l\r'

I have tried other versions and the relationship seems to be as follows. The number of characters that can be stored in the QR Code × Number of Structured Append - (Number of Structured Append + 1)

version=5, (max=106) 106*5-5-1=524 ★The number of characters that can be stored in the QR Code => [https://www.qrcode.com/en/about/version.html](url) It may be the specification of my QR code reader, but it seems that if the above number is exceeded, the last character is replaced by .
heuer commented 2 years ago

Thanks for your report and sorry for the delay.

Which QR code reader do you use?

rabbittyu commented 2 years ago

Thank you for your response.

I am using the QR code reader. https://www.keyence.co.jp/products/barcode/handheld-scanners/hr-100/

This QR code reader can output strings as binary data. If you have a similar application, I would appreciate it if you could try it.

Incidentally, when we tried to work with a smartphone application that supports the following Structured Append QR code, the application crashed. https://apps.apple.com/JP/app/id480090210?mt=8

heuer commented 2 years ago

Thanks for your feedback.

I can confirm that some QR codes in Structured Append mode cannot be read. I'll check what's going wrong.

I was able to install the mentioned Mediaseek Inc. app but it does not support Structured Append mode. It treats each QR code in the sequence as a standalone QR code.

Maybe you can test the handheld with the following QR codes (taken from the ISO standard):

figure-29-iso-18004

It should decode "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

I used Quickmark http://www.quickmark.com.tw/En/basic/index.asp to test the output for Structured Append. Unfortunately, the app isn't available for Android anymore. At least I cannot find it in the Play store and I only sometimes have access to an iOS device

Anyway, I'll check what's going wrong.

rabbittyu commented 2 years ago

Thank you for your time.

We look forward to seeing you soon.