2
Copyright (C) 2007 Martin Owens
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
encode = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
30
# Extended encoding maps for full ASCII Code93
35
result[chr(x)] = encode[y]
40
# MapA is eclectic, but B, C, D are all ASCII ranges
41
mapA = getMap([27,28,29,30,31,59,60,61,62,63,91,92,93,94,95,123,124,125,126,127,0,64,96,127,127,127]) # %
42
mapB = getMap(range(1, 26)) # $
43
mapC = getMap(range(33, 58)) # /
44
mapD = getMap(range(97, 122)) # +
46
class Object(Code39.Object):
47
def encode(self, text):
48
# We are only going to extend the Code39 barcodes
51
if mapA.has_key(char):
52
char = '%' + mapA[char]
53
elif mapB.has_key(char):
54
char = '$' + mapB[char]
55
elif mapC.has_key(char):
56
char = '/' + mapC[char]
57
elif mapD.has_key(char):
58
char = '+' + mapD[char]
59
result = result + char
61
return Code39.Object.encode(self, result);