Code 39
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
Code 39Code 39 (also known as "USS Code 39", "Code 3/9", "Code 3 of 9", "USD-3", "Alpha39", "Type 39") is a barcode symbology that can encode uppercase letters (A through Z), digits (0 through 9) and a handful of special characters like the $ sign. The barcode itself does not contain a check digit (in contrast to—for instance—Code 128), but it can be considered self-checking by some, on the grounds that a single erroneously interpreted bar cannot generate another valid character. Possibly the most serious drawback of Code 39 is its low data density: It requires more space to encode data in Code 39 than, for example, in Code 128. This means that very small goods cannot be labeled with a Code 39 based barcode. However, Code 39 is still widely used and can be decoded with virtually any barcode reader. The name Code 39 is derived from the fact that three of the nine elements that constitute a codeword are wide elements, the remaining six are narrow. Code 39 was developed by Dr. David Allais and Ray Stevens of Intermec in 1974. It was later standardised as ANSI MH 10.8 M-1983 and MIL-STD-1189. The width ratio between narrow and wide can be chosen between 1:2 and 1:3.
EncodingThe * character presented below is not a true encodable character, but is the start and stop 'symbol' for Code 39. The asymmetry of the symbol allows the reader to determine the direction of the barcode being scanned. This code is traditionally mapped to the * character in barcode fonts and will often appear with the human-readable representation alongside the barcode. These tables outline the 3 of 9 specification:
Code 39 mod 43Code 39 is sometimes, though rarely, used with an optional modulo 43 check digit. Using it requires this feature to be enabled in the barcode reader. The code with check digit is referred to as Code 39 mod 43. Here is how to do the checksum calculation:
This can be expressed in Visual Basic as: or in Java as (with checking for invalid characters):
public static final String charSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
public static char getChecksum(String barCode) throws Exception {
int total = 0;
CharacterIterator it = new StringCharacterIterator(barCode);
for (char ch = it.current(); ch != CharacterIterator.DONE; ch = it.next()) {
int charValue = charSet.indexOf(ch);
if (charValue == -1) {
// Invalid character.
throw new Exception("Input String '" +barCode+ "' contains characters that are invalid in a Code39 barcode.");
}
total += charValue;
}
int checksum = total % 43;
return charSet.charAt(checksum);
}
or in C# as
public string ValidateMod43(string barcode)
{
int subtotal = 0;
const string charSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
for (int i = 0; i < barcode.Length; i++)
{
subtotal += charSet.IndexOf(barcode.Substring(i, 1));
}
return charSet.Substring(subtotal%43, 1);
}
or in Perl as Full ASCII Code 39Code 39 is restricted to 44 characters. In Full ASCII Code 39 Symbols 0-9, A-Z, "." ,and "-" are the same as their representations in Code 39. Lower case letters, additional punctuation characters and control characters are represented by sequences of two characters of Code 39.
de:Code39 es:Code 39 fr:Code 39 hr:Kôd 39 nl:Code 39 ja:CODE39 pl:Code 39 uk:Code 39 Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement