Encode extended ASCII characters in a Code 128 barcode
Asked Answered
E

1

4

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.

Entertaining answered 31/1, 2014 at 8:24 Comment(3)
Extended ASCII is a concept rather than a precisely defined thing. Please specify your encoding exactly. If you are asking for a library to do this, then that is off topic.Winifredwinikka
Hey David Thanks for the comment, but i just want to know how we can use FNC4 to encode such extended ASCII character (Special characters like Ñ).i am not looking for library, i am already having encoding logic for encoding the characters upto 128 ASCII value. here is the wiki refernce: en.wikipedia.org/wiki/Code_128Entertaining
Well, as I already said, extended ASCII is a concept rather than a precisely defined thing. You cannot "encode as extended ASCII". You need to pick an actual encoding.Winifredwinikka
N
8

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

"FNC4 is used to represent an extended character set (byte values 128 to 255) as specified in ISO/IEC 8859-1 ... If a single FNC4 character is used, the value 128 is added to the ISO/IEC 646 value of the following data character in the symbol ... Subsequent data characters revert to the standard ISO/IEC 646 set. If two consecutive FNC4 characters are used, the value 128 is added to the ISO/IEC 646 value of all following data characters until two further consecutive FNC4 characters are encountered or the end of the symbol is reached." — ISO/IEC 15417 §4.3.4.2 (d)

In effect, a single FNC4 character toggles the high-bit of the next character (treated as an 8-bit ordinal), whereas two adjacent FNC4 characters toggles the high-bit for subsequent characters.

In your example "QuiÑones" the character "Ñ" is represented by byte value 209 in ISO-8859-1, 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"

Nursery answered 18/5, 2015 at 16:19 Comment(3)
FNC4 characters are analogous to Unicode's Private Use area codepoints. Code 128 doesn't say what the characters are. The writer and reader would have to agree on their meaning. Typically, you would pick numeric values to encode characters the same as in a well-defined character encoding. "Extended ASCII" is not well-defined; neither is "most code pages.". Whether using an established character encoding or making one up, you still have say what it is.Directory
Regarding use of FNC4, not true. ISO/IEC 15417 §4.3.4.2 (d): "FNC4 is used to represent an extended character set (byte values 128 to 255) as specified in ISO/IEC 8859-1 ... If a single FNC4 character is used, the value 128 is added to the ISO/IEC 646 value of the following data character in the symbol ... Subsequent data characters revert to the standard ISO/IEC 646 set. If two consecutive FNC4 characters are used, the value 128 is added to the ISO/IEC 646 value of all following data characters until two further consecutive FNC4 characters are encountered or the end of the symbol is reached."Nursery
Regarding use of term "Extended ASCII", thanks. I've improved the answer by dropping casual references to extended ASCII except in direct reference to the question and made it clear that the Latin1 character set is required for open applications. Thanks again.Nursery

© 2022 - 2024 — McMap. All rights reserved.