mintware-de / flutter_barcode_reader

A flutter plugin for reading 2D barcodes and QR codes.
MIT License
628 stars 464 forks source link

How to decode FNC1 codes in GS1-128 barcode? #233

Closed solartes closed 3 years ago

solartes commented 4 years ago

Summary of the problem

I want to decode the FNC1 codes in GS1-128 barcode.

We know the GS1-128 structure is the following:

https://i.stack.imgur.com/MKixg.png

and GS1-128 uses application identifiers to describe information contained in a barcode, in above image we can see I use 420 routing aplication identifier followed by rounting information, when the information followed by the identifier code is variable we use FNC1 separator.

https://i.stack.imgur.com/e2Mg3.png

Goal

I need to know where is the FNC1 code in order to know where a new aplication identifier starts.

What I have done

I'm using barcode_scan and my code is the following:

  ScanOptions options = ScanOptions(
    useCamera: -1,
  );
  ScanResult result = await BarcodeScanner.scan(options: options);
  print(result.rawContent);

What I get is 420 123456789 92 123 912345678 1234567 1 what I expect is 420 123456789{FNC1}92 123 912345678 1234567 1

ElectricCookie commented 3 years ago

You can use the utf8.encode and utf8.decode functionality to get control characters as byte representations :)