2016-09-29 4 views
1

アラビア語でQR名を生成してスキャンし、生成するためにzxingライブラリを使用しますが、生成された名前をスキャンすると????が返されるので、zxingライブラリはアラビア語をサポートしていないようです。解決策は何ですか?アラビア語のQRコードを生成

これが生成するための私のコードです:

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

答えて

1

する必要がありますあなたのコードに基づいてそう Hashtable hints = new Hashtable(); hints.put(EncodeHintType.CHARACTER_SET, "utf-8");

、私は解決策を見つけた:

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); 
0

はテキストエンコーディングを設定することを忘れてはいけません。それは multiFormatWriter.encode(text2QR, BarcodeFormat.QR_CODE, 500, 500, hints);

+0

あなたがエンコードされたQRコードをデコードんか –

+0

@MarkMamdouh、同じ問題が動作しませんでしたか?スキャナ/リーダがUnicode/Arabicをサポートしていない可能性はありますか? – hakim

+0

私はアラビア語を読み込もうとしましたが、うまくいきましたが、問題はそれを生成することです –

関連する問題