Decode Non-English Characters in 2D Barcodes
Contents
[
Hide
]
You can recognize 2D barcodes for non-English character sets, for example, Turkish, Chinese, Arabic, Latin, Greek and so on. The character limitation is 1000. The sample codes below recognizes barcodes for Turkish and Chinese characters.
Below are code snippets that recognize a Pdf417 barcode for Turkish and Chinese characters.
Recognize a Pdf417 Barcode with Turkish Characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(RecognizePdf417BarcodeWithTurkishCharacters.class) + "TechnicalArticles/"; | |
// Load barcode image | |
BarCodeReader reader = new BarCodeReader(dataDir + "barcode.png", DecodeType.PDF_417); | |
// Read barcode | |
for (BarCodeResult result : reader.readBarCodes()) { | |
// Get byte array and decode | |
byte[] bytes = result.getCodeBytes(); | |
ByteBuffer bytebuf = ByteBuffer.wrap(bytes); | |
System.out.println(Charset.forName("windows-1254").decode(bytebuf).toString()); | |
} |
![]() |
---|
Figure: Sample Turkish Pdf417 barcode |
Recognize a Pdf417 Barcode with Chinese Characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dataDir = Utils.getDataDir(RecognizePdf417BarcodeWithChineseCharacters.class) + "TechnicalArticles/"; | |
// Load barcode image | |
BarCodeReader reader = new BarCodeReader(dataDir + "barcode.png", DecodeType.PDF_417); | |
// Read barcode | |
for (BarCodeResult result : reader.readBarCodes()) { | |
// Get byte array and decode | |
byte[] bytes = result.getCodeBytes(); | |
ByteBuffer bytebuf = ByteBuffer.wrap(bytes); | |
System.out.println(Charset.forName("MS936").decode(bytebuf).toString()); | |
} |
![]() |
---|
Figure: A sample Chinese Pdf417 barcode |