zoukankan      html  css  js  c++  java
  • jQuery qrcode生成二维码

    qrcode.js 是实现二维码计算的核心类

    jQuery.qrcode.js 把它用jQuery封装起来,用来实现图像渲染 也就是画图。支持table和canvas

    所需环境:jQuery.min.js压缩文件(或jQuery.js)

         jQuery.qrcode.min.js压缩文件(或 jQuery.qrcode.js  qrcode.js源文件)

         utf16to8.js。因为qrcode不支持中文,所以需要将Unicode编码转出utf-8编码,不涉及中文就不用该方法。

    生成二维码代码:

      $("#qrcodeCanvas).qrcode({render:"canvas",256,height:256,text:"https://www.baidu.com"});  若是中文:text:utf16to8("王小小")

    utf16to8.js代码

    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;
    }

  • 相关阅读:
    git的命令操作指南
    【flask】RestFul的基本鉴权
    linux断电修复
    centos7安装libreoffice
    java -jar 后台启动
    yum安装nginx
    rpm安装mysql
    yum安装redis
    Centos 修改yum源
    centos8安装node.js v12.18.3
  • 原文地址:https://www.cnblogs.com/wxwBlog/p/5888311.html
Copyright © 2011-2022 走看看