Create QRCode to be opened URL in browser

Viewed 101

In my application I need to show a QRCode that embeds a URL to be opened in a browser. I'm using the Nayuki library in my Qt/C++ application and I encode this string:

"http://mydevice.local"

but my device (Android) decodes it as a literal string, asking me if I want to copy the text. Encoding a commercial website, say:

"http://www.google.com"

instead works as expected, asking me if I want to open the URL in a browser. Because the protocol is not enough to trigger this feature, how I need to encode such a URL?

1 Answers

If http://www.google.com works, but http://mydevice.local doesn't, then it's probably not an encoding problem. Maybe the library that decodes qr codes on your device simply doesn't recognize .local as a valid TLD.

I don't have an android device on hand, but an iphone running IOS 15.1 opens a browser with the desired url for both urls.

for reference, here are the qr codes I used (generated using qrencode -t ansiutf8):

http://mydevice.local:

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █▄▄▄ ▀█▄███ ▄▄▄▄▄ ████
████ █   █ ██▄▀ █ ▄ ▀█ █   █ ████
████ █▄▄▄█ ██▀▄ ▄▀▄█ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄█ ▀▄▀ █▄▄▄▄▄▄▄████
████▄ █ ▄█▄▀▀▄▀█▄█ ▀ █▄▀▀▀▀▀▄████
████▄▀▀▄  ▄▄▀▄██▄█ ▄▄▀ ▄  ▀▀ ████
████ ██  ▀▄█▀▄ █▀█▀  █▄█▀██▀▄████
████ ▄ ▄█▀▄   ▄█▀▄  ▀  ▀█▄ ▄ ████
████▄██▄█▄▄█▀▄▄ ▄▀▄▄ ▄▄▄ █▄ █████
████ ▄▄▄▄▄ ███▄▀▄▀ ▀ █▄█ ▄██▄████
████ █   █ █ ▀▀▄▀ ▀    ▄▄ █  ████
████ █▄▄▄█ █▀ ▄ ▀ █▄▄█▀  █   ████
████▄▄▄▄▄▄▄█▄▄▄▄▄▄██▄▄███▄██▄████
█████████████████████████████████
█████████████████████████████████

http://www.google.com:

█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █▄▄▄ ▀█▄█ █ ▄▄▄▄▄ ████
████ █   █ ██▄▀ █ █▄▀█ █   █ ████
████ █▄▄▄█ ██▀▄ ▄▀▄█ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄█ ▀▄█ █▄▄▄▄▄▄▄████
████  █  █▄██▄▀█▄▀ ▀▄▀▄▀▀▀▀▀▄████
████ ▀▄█▄▄▄▀▄▄██▄▄▀ ▄█▄ █ ▀▀ ████
████ █▀█▄▄▄▀█  █▀█▀  ▄▄█▀██▀▄████
████ ▄ ▀█▀▄▄▄  █▀▄▄ █▄█▀ ▄ ▄ ████
████▄███▄▄▄█▀ ▀ ▄▀▄█ ▄▄▄ █▄ █████
████ ▄▄▄▄▄ ██ ▀▀▄▀ ▀ █▄█ ▄██▄████
████ █   █ █ ▄█▄▀ ▀ ▄   ▄ █  ████
████ █▄▄▄█ █▀▄▄ ▀ ██▄▄▀  █   ████
████▄▄▄▄▄▄▄█▄█▄▄▄▄██▄████▄██▄████
█████████████████████████████████
█████████████████████████████████
Related