[reportlab-users] Code 39 Check digit bug ?

Ian Cottee icottee at bluefountain.com
Fri Jul 3 06:01:02 EDT 2009


Using reportlab2.2, with python2.5 on Mac OSX

from reportlab.graphics.barcode import code39
In [2]: bc1 = code39.Extended39('48281450412')

In [4]: bc1.validate()
Out[4]: '48281450412'

In [5]: bc1.encode()
Out[5]: '*48281450412**'

That check digit of '*' appears to be wrong. Our clients can't scan
the code and the docs would appear to say that it should be a '$'.

Using the code from Wikipedia at

http://en.wikipedia.org/wiki/Code_39

def append_c39_checksum(st):
charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
return st + charset[ sum(charset.index(c) for c in st) % 43 ]

In [8]: append_c39_checksum('48281450412')
Out[8]: '48281450412$'

Is this a known issue or a misunderstanding on my part? It only
appears to happen when the checkdigit sum is 39. We have the same
result on the clients system which is running Ubuntu 8.04

Many thanks

Ian Cottee
Blue Fountain Systems Ltd


More information about the reportlab-users mailing list