I’m trying to do this extremely (or so I thought) simple thing:
-
On device A: Type in a string in a text field
-
On device A: Generate a QR code based on this string with the great QRGenerator library from torbenratzlaff.
-
On device B: Scan this QR code with the QR Scanner plugin
-
On device B: Display this text on a text field
This works well for standard characters, but as soon as some special characters are involved it goes ad undas. Surely there is some UTF-8 stuff going on, but I just cannot crack it.
In the attached small example app, there is one text field and as text is entered a qr code is generated. The string is json encoded (because originally there are several strings in a list) and the JSON encoded list look like this in the log from “transmitting app” (when entering the word “døv”).
{“s”:“døv”}
This is also how it look if I scan this with a third party app like QR Code Reader.
But if I scan the exact same image with the QR Scanner plugin (with another device) the read JSON encoded string shows like this in the log (using adb logcat):
{“s”:“d∩╛â∩╜╕v”}
And showing the JSON encoded string directly in the app shows like this:
That the log showing in a Windows cmd window isn’t correct isn’t all that surprising, but how the string showing in the app itself becomes that garbled is a problem.
I’ve tried to use some utf8_decode code on the string, but that doesn’t seem to work either…
Is there any foolproof way of doing this string transfer safely?