code-39

Details on the code-39 bar code type.

Note: An example of a code-39 bar code can be seen in the Reports demo: OrderStock.4rp.
Table 1. Characters for encoding ASCII text of variable length for Code 39
Reference Number Character
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 A
11 B
12 C
13 D
14 E
15 F
16 G
17 H
18 I
19 J
20 K
21 L
22 M
23 N
24 O
25 P
26 Q
27 R
28 S
29 T
30 U
31 V
32 W
33 X
34 Y
35 Z
36 -
37 .
38
39 $
40 /
41 +
42 %

The last but one character is the checksum character that is calculated as follows:CS=Sum(i=1 to n of Ref(i))) mod 43 where Ref(i) is the reference number of the character i, and n is the total number of characters. Example: codeValue="DATALOGIC"CS=(13+10+29+10+21+24+16+18+12) mod 43,CS=153 mod 43,CS=24 Looking up reference number 24 yields the character 'O'. The full code value including checksum and stop character is therefore: codeValue="DATALOGICO"

Some scanners support an "extended mode" in which the scanner recognizes special two-character sequences of the code 39 character set and decodes these as ASCII characters. With this method the full 128 character ASCII character set can be encoded using the 43 basic characters of code 39. Scanners are switched into "extended mode" by a bar containing the sequence "+$". The sequence "-$" returns the scanner into regular mode. This table lists the character sequences needed to encode the ASCII character set in "extended mode".

Table 2. Character sequences needed to encode the ASCII character set in "extended mode"
ASCII code Code 39 sequence
NUL %U
SOH $A
STX $B
ETX $C
EOT $D
ENQ $E
ACK $F
BEL $G
BS $H
HT $I
LF $J
VT $K
FF $L
CR $M
SO $N
SI $O
DLE $P
DC1 $Q
DC2 $R
DC3 $S
DC4 $T
NAK $U
SYN $V
ETB $W
CAN $X
EM $Y
SUB $Z
ESC %A
FS %B
GS %C
RS %D
US %E
SP
! /A
" /B
# /C
$ /D
% /E
& /F
' /G
( /H
) /I
* /J
+ /K
, /L
- -
. .
/ /O
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
: /Z
; %F
< %G
= %H
> %I
? %J
@ %V
A A
B B
C C
D D
E E
F F
G G
H H
I I
J J
K K
L L
M M
N N
O O
P P
Q Q
R R
S S
T T
U U
V V
W W
X X
Y Y
Z Z
[ %K
\ %L
] %M
^ %N
_ %O
` %W
a +A
b +B
c +C
d +D
e +E
f +F
g +G
h +H
i +I
j +J
k +K
l +L
m +M
n +N
o +O
p +P
q +Q
r +R
s +S
t +T
u +U
v +V
w +W
x +X
y +Y
z +Z
{ %P
| %Q
} %R
~ %S
DEL %T

The code type "code 39 extended" automatically creates the necessary two-character sequences and can be used as a more convenient way of creating extended code 39 bar codes.

If the value specified by codeValue is shorter by one character than the number of digits specified by noDigits then the checksum character is automatically calculated and the character is appended to codeValue.

The nominal height is 1in. The nominal width of a thin bar is THINBARWIDTH=0.0197in. The width of a thick bar is THICKBARWIDTH=THINBARWIDTH/ thinToThickRelation where thinToThickRelation should take values between1/3 and1/2. Between digits a gap with the width GAPWIDTH=THINBARWIDTH/ thinToGapRelation is drawn. The default relation value is 1. The padding on both sides measures 10*THINBARWIDTH.