jeromeetienne / jquery-qrcode

qrcode generation standalone (doesn't depend on external services)
http://blog.jetienne.com/blog/2011/04/07/jquery-qrcode/
MIT License
4.84k stars 2.5k forks source link

Bugs!! #73

Open zj3782 opened 9 years ago

zj3782 commented 9 years ago

When I use below codes to generate the qrcode, the generated qrcode can not be decoded.

function utf16to8(str) {
    var out, i, len, c;
    out = "";
    len = str.length;
    for (i = 0; i < len; i++) {
        c = str.charCodeAt(i);
        if ((c >= 0x0001) && (c <= 0x007F)) {
            out += str.charAt(i);
        } else if (c > 0x07FF) {
            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
            out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
            out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
        } else {
            out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
            out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
        }
    }
    return out;
}

var text = "http://jiceshi.heimalanshi.com/test?id=9";
var op={};
op.width=200;
op.height=200;
op.text=utf16to8(text);
op.render = "table";
jQuery('#qrcode').qrcode(op);

The generated qrcode is shown as below: table

But when I remove op.render = "table";, the generated qrcode can be decoded. canve

fangge commented 8 years ago

This bug shown in my page too.

woden0415 commented 7 years ago

hello,I also meet this problem. my url is "http://10.181.65.222:9504/content/guizhou/news/infodetail.544287728101533.html". default type "canvas" to render is right. I look at the source code lot of time ,debuging many times ,could not find the real reason. help help