codebude / QRCoder

A pure C# Open Source QR Code implementation
MIT License
4.56k stars 1.09k forks source link

Is it possible to force QR code type to text instead of URI? #144

Closed Floppe closed 5 years ago

Floppe commented 5 years ago

Type of issue

[ ] Bug
[X ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement

Expected Behavior

Plain text when scanned. QR encoding "https://website.com/" should show only the text, not open the URL.

Current Behavior

Type is URI, so Android tries to open URL.

codebude commented 5 years ago

This is nothing which is handled by QRCoder. When you enter an URL as text, it is encoded as text. When readers open the URL instantly in a browser than this is done in the code of the reader app. A lot of readers open URLs directly when they see that there's only a URL in a QRCode.

Proof: try to read out the generated QR code with a web-based QR code reader in your browser. You will see that it contains no commands, just the plain URL.

Workaround: If you want to ensure that readers don't open the link immediately, prefix your URL like: "Url: http://myserver.com"

Floppe commented 5 years ago

Oh. I wonder then how for example http://goqr.me/ does handle this. I've used this service to create texts which starts with URLs. And no prefix used.

codebude commented 5 years ago

An their codes, scanned with the same reader app, doesn't launch the webbrowser? If so, could you please post two examples codes. One from the mentioned generator and one from QRCoder you generated? I would like to debug and compare them.

Maybe you have an error in the QR generating code?

With the following coding, I get exact the same payload like I get when usig goqr.me - so it behaves completely the same:

QRCodeGenerator.ECCLevel eccLevel = QRCodeGenerator.ECCLevel.L;
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
{
    using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("https://code-bude.net", eccLevel))
    {
        using (QRCode qrCode = new QRCode(qrCodeData))
        {
            pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White);
        }
    }
}
Floppe commented 5 years ago

Yes, My bad. I'm sorry. There were a linefeed and a suffix which I missed when the payload was URL encoded. Decoded and the results are the same when scanning the codes.

codebude commented 5 years ago

No problem. You're welcome. :-)