g0dkar / qrcode-kotlin

QRCode Generator implemented in pure Kotlin
https://qrcodekotlin.com/
MIT License
172 stars 16 forks source link

Strange encoding with number #4

Closed pvarry closed 2 years ago

pvarry commented 2 years ago

Describe the bug When a create a QrCode with only number, it's encode content as byte array and some very common tools can't display content.

To Reproduce

QRCode("123456").render()
QRCode("123456b").render()

When I encode :

PS: I used https://zxing.org/w/decode.jspx to decode QrCode

Expected behavior

To generate a QrCode with correct String encoded and be able to decode it with most tools.

The solution can be to create a other constructor who can receive a Byte Array and use the current one only for String OR to add a parameter to specify input type.

g0dkar commented 2 years ago

Hey @pvarry, just an update: I'm almost pinpointing what is the cause if the issue ^^

I think I'll be fixing the issues today or tomorrow!

g0dkar commented 2 years ago

@pvarry can you check if with v1.2.1 the issue is fixed? I've tested it with some phones and it seemed to be working. I could reproduce your reported case, and I've fixed the issues causing it.

I've also added a dataType parameter to the QRCode class constructor with which you can specify a data type for what you want to encode into the QRCode. By default it'll try to guess from the contents of the string, just like before :)

pvarry commented 2 years ago

I tested the new release and it's work perfectly in my use case, I can use QRCode("123456").render() with specific data type and it's correctly render QrCode.

dataType work also great.

Thanks for the fix.