为了账号安全,请及时绑定邮箱和手机立即绑定

中文的乱码

大神们,中文乱码怎么解决啊

正在回答

2 回答

如果是jQuery:

jQuery('#qrcode2').qrcode({

text: utf16to8("中文支持")

});

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;

};

如果是前两种zxing和qrcode

hashMap.put(EncodeHintType.CHARACTER_SET, "utf-8");

指定编码方式为UTF-8即可

0 回复 有任何疑惑可以回复我~

求代码!

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java生成二维码
  • 参与学习       84389    人
  • 解答问题       203    个

二维码无处不在,自己动手用Java生成二维码,三种生成方式任你选

进入课程

中文的乱码

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信