5.2 Barcode Encodings
Barcodes are always transmitted in a binary format. Because we don't know which encoding your barcode is using, we currently use WINDOWS-1252 as the standard encoding. It includes all ASCII and Western European characters including the € sign.
If your codes have a different encoding, such as UTF-8, you have to decode them yourself or use the built-in library functions to convert the byte array to a string.
We currently support the following encodings:
- WINDOWS-1252
- UTF-8
- ISO-8859-1
You can access the raw byte array like this:
override fun didScanBarcode(device: NIMMSTADevice, barcode: Barcode, event: ScanEvent) {
// Both examples are equivalent
event.encodedBarcode.asWindows1252String()
event.encodedBarcode.toString(NIMMSTAEncoding.WINDOWS_1252)
// Both examples are equivalent
event.encodedBarcode.asUTF8String()
event.encodedBarcode.toString(NIMMSTAEncoding.UTF_8)
// Both examples are equivalent
event.encodedBarcode.toString(NIMMSTAEncoding.WINDOWS_1252)
event.encodedBarcode.asWindows1252String()
// Access the underlying byte array
event.encodedBarcode.byteArray
}
@Override
public void didScanBarcode(NIMMSTADevice nimmstaDevice, Barcode barcode, ScanEvent scanEvent) {
// Both examples are equivalent
scanEvent.encodedBarcode.asWindows1252String();
scanEvent.encodedBarcode.toString(NIMMSTAEncoding.WINDOWS_1252);
// Both examples are equivalent
scanEvent.encodedBarcode.asUTF8String();
scanEvent.encodedBarcode.toString(NIMMSTAEncoding.UTF_8);
// Both examples are equivalent
scanEvent.encodedBarcode.toString(NIMMSTAEncoding.WINDOWS_1252);
scanEvent.encodedBarcode.asWindows1252String();
// Access the underlying byte array
scanEvent.encodedBarcode.byteArray;
}
You can change the standard encoding at any time like this: