課程
/后端開發(fā)
/Java
/Java生成二維碼
大神們,中文亂碼怎么解決啊
2017-06-27
源自:Java生成二維碼 6-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即可
求代碼!
舉報
二維碼無處不在,自己動手用Java生成二維碼,三種生成方式任你選
2 回答中文亂碼了
5 回答VCard中文亂碼
2 回答中文亂碼怎么改?
1 回答中文會亂碼 怎么解決呀?
3 回答二維碼內(nèi)容是中文時輸出亂碼
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-09-13
如果是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即可
2017-06-27
求代碼!