課程
/后端開發(fā)
/Java
/Java生成二維碼
中文會亂碼 怎么解決呀?
2016-11-23
源自:Java生成二維碼 7-1
正在回答
try {?? ??? ??? ?//加上此段代碼會解決中文亂碼問題?? ??? ??? ?content = new String(content.getBytes("UTF-8"), "ISO-8859-1");?? ??? ??? ?BitMatrix bitMatrix? = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);?? ??? ??? ?Path file = new File("D:/img.png").toPath();?? ??? ??? ?MatrixToImageWriter.writeToPath(bitMatrix, format, file);?? ??? ?} catch (Exception e) {?? ??? ??? ?e.printStackTrace();?? ??? ?}
舉報
二維碼無處不在,自己動手用Java生成二維碼,三種生成方式任你選
1 回答亂碼問題怎么解決
2 回答中文亂碼怎么改?
2 回答中文的亂碼
2 回答中文亂碼了
5 回答VCard中文亂碼
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-11-23
try {
?? ??? ??? ?//加上此段代碼會解決中文亂碼問題
?? ??? ??? ?content = new String(content.getBytes("UTF-8"), "ISO-8859-1");
?? ??? ??? ?BitMatrix bitMatrix? = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);
?? ??? ??? ?Path file = new File("D:/img.png").toPath();
?? ??? ??? ?MatrixToImageWriter.writeToPath(bitMatrix, format, file);
?? ??? ?} catch (Exception e) {
?? ??? ??? ?e.printStackTrace();
?? ??? ?}