Parsing FNC1 character with bwip-js gs1datamatrix

1.4k views Asked by At

What I want is to generate a GS1 datamatrix using the bwip-js API with a FNC1 passed in.

I have tried the example provided in their website (Online Barcode API documentation) throught Postman and it returns the correct value back (ie. without the FNC1 character in the scanned result).

Their example request (parses FNC1 correctly)

http://bwipjs-api.metafloor.com/?bcid=code128&text=%5EFNC1011234567890&parsefnc&alttext=%2801%291234567890

However when I use my example for the GS1 data matrix, with the FNC1 value, I get the FNC1 in the scanned result. So it is not parsing the FNC1 value correctly.

My request (does not parse FNC1 correctly):

http://bwipjs-api.metafloor.com/?bcid=gs1datamatrix&text=%5EFNC1(01)03453120000011(17)120508(10)ABCD1234(410)9501101020917&parsefnc&alttext=%2801%291234567890

I have read all the documentation and articles I can find about their generator and the FNC1 character, but didn't give me any clues.

Am I doing anything wrong here?

UPDATE:

The input to BWIP-JS:

(01)99312650999998(91)111JD507496002000960300(420)2164(8008)181102113732

Image generated:

enter image description here

2

There are 2 answers

6
charlesbridge On BEST ANSWER

The code in bwip-js is PostScript and I'm no expert in that language. But try taking the 'FNC1' out of your request and see if that works.

I think it's trying to automatically add FNC1 to any GS1 Datamatrix (see section starting a line 23903) when it sees an AI, whereas for Data Matrix it has to be explicitly requested.

0
Brian Berneker On

The FNC1 character is invisible to the console, so it can be tricky to see, but I've managed to parse it out of raw strings using the following:

var decoded = decodedString.split(decodeURI("%1D"));

If you're getting the FNC codes in parentheses, you could probably use a REGEX to remove them.