• 利用JS生成二维码图片,支持中文


    转自cloud.tencent.com/developer/article/1068483

    只贴快速使用的片段了

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="//cdn.bootcss.com/jquery/1.8.2/jquery.min.js"></script>
        <script src="//cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <div id="output"></div>
                <script type="text/javascript">
                    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;
                    }
                    content = utf16to8('手机扫一扫,精彩随声带!');
                    $('#output').qrcode({
                         200,
                        height: 200,
                        render: "canvas",
                        correctLevel: 0,
                        text: content
                    });
                </script>
            </div>
        </form>
    </body>
    </html>
  • 相关阅读:
    map初始化
    map
    sort排序
    455分发饼干
    392判断子序列
    vector遍历
    vector删除数据
    VC-进程间通信(InterProcess Communication,IPC)
    Oracle 11g 安装和登录(windows)
    控制台输出宽字符wchar_t的中文显示问题
  • 原文地址:https://www.cnblogs.com/wybshyy/p/13783687.html
Copyright © 2020-2023  润新知