Mayank R Jain
Mayank R Jain

Reputation: 3147

Encoding a string in 128c barcode symbology

I am having some trouble with encoding this string into barcode symbology - Code 128.

Text to encode: 1021448642241082212700794828592311

I am using the universal encoder from idautomation.com: https://www.bcgen.com/fontencoder/

I get the following output for the encoded text for Code 128: Í*5LvJ8*r5;ÂoP<[7+.Î

However, in ";Âo" the character between the semi-colon and o (let us call it special A) - is not part of the extended character set used in Code128. (See the Latin Supplements at https://www.fonts2u.com/code-128.font)

Yet the same string shows a valid barcode at https://www.bcgen.com/linear-barcode-creator.html

How?

If I use the output with the Special A on a webpage with a font face for barcodes, the special A character does not show up as the barcode (and that seems correct since the special A is not part of the character set).

What gives? Please help.

I am using the IDAutomation utility to encode the string to 128c symbology. If you can share code to do the encoding (in Java/Python/C/Perl) that would help too.

Upvotes: 6

Views: 9821

Answers (2)

Anbaric
Anbaric

Reputation: 11

Sorry, this is very late.

When you are dealing with the encoding of code 128, in any subset, it's a good idea to think of that coding in terms of numbers, not characters. At this level, when you have shifts, code-changes, checksums and stuff, intermixed with the data, the whole concept of "character" is lost.

However, this is what is happening:

The semicolon in the output corresponds to "27" The lowercase o corresponds to "48" and the P to "79"

The "A with Macron" corresponds to your "00" sequence. This is why you should be dealing with numbers, not characters, at this level of encoding.

How would you expect it to show a character with a code of 00 ? That would be a space of NULL, neither of which is particularly visible.

Your software has simply rendered it the best way it can, which is to make the character 'visible' by adding 0x80 to it. If you look at charmap, you will see that code 0x80 is indeed A with macron.

The rest (indeed all) of your encoded string looks correct for a setc-encodation.

Upvotes: 0

Durandal
Durandal

Reputation: 20059

There are multiple fonts for Code128 that may use different characters to represent the barcode symbols. Make sure the font and the encoding logic match each other.

I used this one http://www.jtbarton.com/Barcodes/Code128.aspx (there is also sample code how to encode it on the site, but you have to translate it from VB). The font works for all three encodings (A, B and C).

Upvotes: 2

Related Questions