Encode extended ASCII characters in a Code 128 bar

2019-01-28 12:00发布

I want to encode the string "QuiÑones" in a Code 128 bar code. Is it possible to include extended ASCII characters in the Code 128 encoding? .

I did some research on Google which suggested that it is possible by using FNC4, but I didn't find exactly how to do it. It would be of great help if some one could assist me with a solution in the C language.

1条回答
三岁会撩人
2楼-- · 2019-01-28 12:18

"Extended ASCII" characters with byte values from 128 to 255 can indeed be represented in Code 128 encodation by using the special FNC4 function character. For general use (in open applications) it is necessary that such characters belong to the ISO-8859-1 (Latin1) character set.

A single FNC4 character acts as a shift to the extended character set for the next character whereas two consecutive FNC4 characters act as a latch. The effect is to toggle the high bit (basically to add or subtract 128) of the 8-bit ASCII value of the affected characters.

In your example "QuiÑones" the character "Ñ" is represented by byte value 209 in the default ISO-8859-1 character set, so that's 128+81. ASCII 81 resolves to "Q", so you require the sequence FNC4 Q to represent "Ñ".

An efficient Code 128 encodation of this data is as follows:

[104/START-B] [49/Q] [85/u] [73/i] [100/FNC4] [49/Q] [79/o] [78/n] [69/e] [83/s] [93/check-digit] [106/STOP]

Some barcode applications and libraries will perform the FNC4-based extended character encoding for you, as in the example below. The majority don't but these should allow you to specify an FNC4 character directly so that you can manually drive the process using the above technique, e.g: Qui{FNC4}Qones

The Code 128 symbol looks like this:

Code 128 containing the word "QuiÑones"

It was generated using the Online Barcode Generator with the following options:

Barcode:  Code 128
Contents: Qui^209ones
Options:  parse height=0.5
查看更多
登录 后发表回答