Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Code 128
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Barcode length optimization by Code 128 Type-C=== Code set C uses one code symbol to represent two digits. Thus it may create shorter barcodes if the content consists of numbers only or if there are longer sequences of digits within the code. However, when the string contains only a few digits or it's mixed with non-digit character, it does not always produce a more compact code than code sets A or B. Using code set C saves one symbol per two digits, but costs a mode-shift symbol to enter and exit the set. Thus, it is only worth using if there are enough consecutive digits. For example, encoding the string "X00Y" with code set A or B requires 7 code symbols (<code>[Start B] 56 16 16 57 [checksum] [Stop]</code>), while using code set C for the "X00Y" would result in a code 8 symbols long (<code>[Start B] 56 [Code C] 00 [Code B] 57 [checksum] [Stop]</code>). Using code set C is only advantageous under the following conditions: {| class="wikitable" |- ! Location of digits !! Number of consecutive digits |- | beginning of data || 4+ |- | end of data || 4+ |- | middle of data (surrounded by symbols from code set A or B) || 6+ |- | entire data || either 2 or 4+ (but not 3) |} At the end of a string, delaying the transition to code set C until there are an even number of digits remaining avoids an extra symbol. Consider the string "...01234": a delayed switch produces <code>... 0 [Code C] 12 34 [checksum] [Stop]</code> but an early switch produces <code>... [Code C] 01 23 [Code A] 4 [checksum] [Stop]</code>.<ref>GS1 General Specifications, Version 13, Issue 1, Jan-2013, Section 5.4.7.7. Use of Start, Code Set, and Shift symbols to Minimize Symbol Length (Informative), pages 268 to 269. This section gives the compression strategy.</ref> For example, given the string "098x1234567y23", savings on barcode length using code set C are achieved only if it is applied to middle part of the string. For the beginning and ending part of the string, switching to code set C is not effective. As there are an odd number of digits in the middle of the string, the odd one must use a different code set, but it makes no difference whether this is the first or last; 16 symbols are required in either case: <code>[Start B] 0 9 8 x 1 [Code C] 23 45 67 [Code B] y 2 3 [checksum] [Stop]</code>, or <code>[Start B] 0 9 8 x [Code C] 12 34 56 [Code B] 7 y 2 3 [checksum] [Stop]</code>. Optimizing the length of the resulting barcode is important when [[barcode reader]]s are used which must detect the entire barcode image at once in order to read it, such as common [[Barcode reader#Laser scanners|laser scanners]]. The longer the barcode is, the greater distance of laser barcode reader from barcode image is needed, making reading difficult or impossible above some threshold lengths/distances. The [[optimal]] encoding can be found using a [[dynamic programming]] algorithm.<ref>{{cite book |title=The Algorithm Design Manual |edition=2nd |first=Steven S. |last=Skiena |author-link=Steven Skiena |year=2010 |isbn=978-1-849-96720-4 |chapter=8.9 War Story: Text Compression for Bar Codes |publisher=Springer |quote=dynamic programming led to an 8% tighter encoding on average.}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)