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
"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: