在我的应用程序中,我生成了一个阿拉伯语的 QR 名称,然后扫描并使用 zxing
库生成,但似乎 zxing
库不支持阿拉伯语,因为当我扫描生成的名称时,它会给我 ????
。解决方案是什么?
这是我要生成的代码:
BitMatrix bitMatrix = multiFormatWriter.encode(text2QR, BarcodeFormat.QR_CODE, 500, 500);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
最佳答案
我找到了解决方案:
MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
Map<EncodeHintType, Object> hintMap = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hintMap.put(EncodeHintType.MARGIN, 1); /* default = 4 */
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
BitMatrix bitMatrix = multiFormatWriter.encode(text2QR, BarcodeFormat.QR_CODE, 500, 500, hintMap);
BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
bitmap = barcodeEncoder.createBitmap(bitMatrix);
imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
关于java - 生成阿拉伯语二维码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39761575/