git.cweiske.de
/
enigma2.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Merge branch 'master' of fraxinas@git.opendreambox.org:/git/enigma2
[enigma2.git]
/
lib
/
python
/
Tools
/
ASCIItranslit.py
1
# -*- coding:utf-8 -*-
2
3
ASCIItranslit = { \
4
0x0022: "''", \
5
0x002A: "_", \
6
0x002F: "_", \
7
0x003A: "_", \
8
0x003C: "_", \
9
0x003D: "_", \
10
0x003E: "_", \
11
0x003F: "_", \
12
0x005C: "_", \
13
0x007C: "_", \
14
0x007F: "", \
15
0x00A0: "_", \
16
0x00A1: "!", \
17
0x00A2: "c", \
18
0x00A3: "lb", \
19
0x00A4: "", \
20
0x00A5: "yen", \
21
0x00A6: "I", \
22
0x00A7: "SS", \
23
0x00A8: "'", \
24
0x00A9: "(c)", \
25
0x00AA: "a", \
26
0x00AB: "<<", \
27
0x00AC: "not", \
28
0x00AD: "-", \
29
0x00AE: "(R)", \
30
0x00AF: "", \
31
0x00B0: "^0", \
32
0x00B1: "+-", \
33
0x00B2: "^2", \
34
0x00B3: "^3", \
35
0x00B4: "'", \
36
0x00B5: "u", \
37
0x00B6: "P", \
38
0x00B7: ".", \
39
0x00B8: ",", \
40
0x00B9: "^1", \
41
0x00BA: "o", \
42
0x00BB: ">>", \
43
0x00BC: "1_4 ", \
44
0x00BD: "1_2 ", \
45
0x00BE: "3_4 ", \
46
0x00BF: "_", \
47
0x00C0: "`A", \
48
0x00C1: "'A", \
49
0x00C2: "^A", \
50
0x00C3: "~A", \
51
0x00C4: "Ae", \
52
0x00C5: "A", \
53
0x00C6: "AE", \
54
0x00C7: "C", \
55
0x00C8: "`E", \
56
0x00C9: "'E", \
57
0x00CA: "^E", \
58
0x00CB: "E", \
59
0x00CC: "`I", \
60
0x00CD: "'I", \
61
0x00CE: "^I", \
62
0x00CF: "I", \
63
0x00D0: "D", \
64
0x00D1: "~N", \
65
0x00D2: "`O", \
66
0x00D3: "'O", \
67
0x00D4: "^O", \
68
0x00D5: "~O", \
69
0x00D6: "Oe", \
70
0x00D7: "x", \
71
0x00D8: "O", \
72
0x00D9: "`U", \
73
0x00DA: "'U", \
74
0x00DB: "^U", \
75
0x00DC: "Ue", \
76
0x00DD: "'Y", \
77
0x00DE: "Th", \
78
0x00DF: "ss", \
79
0x00E0: "`a", \
80
0x00E1: "'a", \
81
0x00E2: "^a", \
82
0x00E3: "~a", \
83
0x00E4: "AE", \
84
0x00E5: "a", \
85
0x00E6: "ae", \
86
0x00E7: "c", \
87
0x00E8: "`e", \
88
0x00E9: "'e", \
89
0x00EA: "^e", \
90
0x00EB: "e", \
91
0x00EC: "`i", \
92
0x00ED: "'i", \
93
0x00EE: "^i", \
94
0x00EF: "i", \
95
0x00F0: "d", \
96
0x00F1: "~n", \
97
0x00F2: "`o", \
98
0x00F3: "'o", \
99
0x00F4: "^o", \
100
0x00F5: "~o", \
101
0x00F6: "oe", \
102
0x00F7: "_", \
103
0x00F8: "o", \
104
0x00F9: "`u", \
105
0x00FA: "'u", \
106
0x00FB: "^u", \
107
0x00FC: "ue", \
108
0x00FD: "'y", \
109
0x00FE: "th", \
110
0x00FF: "Y", \
111
0x0100: "A", \
112
0x0101: "a", \
113
0x0102: "A", \
114
0x0103: "a", \
115
0x0104: "A", \
116
0x0105: "a", \
117
0x0106: "'C", \
118
0x0107: "'c", \
119
0x0108: "^C", \
120
0x0109: "^c", \
121
0x010A: "C", \
122
0x010B: "c", \
123
0x010C: "C", \
124
0x010D: "c", \
125
0x010E: "D", \
126
0x010F: "d", \
127
0x0110: "D", \
128
0x0111: "d", \
129
0x0112: "E", \
130
0x0113: "e", \
131
0x0114: "E", \
132
0x0115: "e", \
133
0x0116: "E", \
134
0x0117: "e", \
135
0x0118: "E", \
136
0x0119: "e", \
137
0x011A: "E", \
138
0x011B: "e", \
139
0x011C: "^G", \
140
0x011D: "^g", \
141
0x011E: "G", \
142
0x011F: "g", \
143
0x0120: "G", \
144
0x0121: "g", \
145
0x0122: "G", \
146
0x0123: "g", \
147
0x0124: "^H", \
148
0x0125: "^h", \
149
0x0126: "H", \
150
0x0127: "h", \
151
0x0128: "~I", \
152
0x0129: "~i", \
153
0x012A: "I", \
154
0x012B: "i", \
155
0x012C: "I", \
156
0x012D: "i", \
157
0x012E: "I", \
158
0x012F: "i", \
159
0x0130: "I", \
160
0x0131: "i", \
161
0x0132: "IJ", \
162
0x0133: "ij", \
163
0x0134: "^J", \
164
0x0135: "^j", \
165
0x0136: "K", \
166
0x0137: "k", \
167
0x0138: "", \
168
0x0139: "L", \
169
0x013A: "l", \
170
0x013B: "L", \
171
0x013C: "l", \
172
0x013D: "L", \
173
0x013E: "l", \
174
0x013F: "L", \
175
0x0140: "l", \
176
0x0141: "L", \
177
0x0142: "l", \
178
0x0143: "'N", \
179
0x0144: "'n", \
180
0x0145: "N", \
181
0x0146: "n", \
182
0x0147: "N", \
183
0x0148: "n", \
184
0x0149: "n", \
185
0x014A: "_", \
186
0x014B: "_", \
187
0x014C: "O", \
188
0x014D: "o", \
189
0x014E: "O", \
190
0x014F: "o", \
191
0x0150: "''o", \
192
0x0152: "OE", \
193
0x0153: "oe", \
194
0x0154: "'R", \
195
0x0155: "'r", \
196
0x0156: "R", \
197
0x0157: "r", \
198
0x0158: "R", \
199
0x0159: "r", \
200
0x015A: "'s", \
201
0x015B: "'s", \
202
0x015C: "^S", \
203
0x015D: "^s", \
204
0x015E: "S", \
205
0x015F: "s", \
206
0x0160: "S", \
207
0x0161: "s", \
208
0x0162: "T", \
209
0x0163: "t", \
210
0x0164: "T", \
211
0x0165: "t", \
212
0x0166: "T", \
213
0x0167: "t", \
214
0x0168: "~U", \
215
0x0169: "~u", \
216
0x016A: "U", \
217
0x016B: "u", \
218
0x016C: "U", \
219
0x016D: "u", \
220
0x016E: "U", \
221
0x016F: "u", \
222
0x0170: "''u", \
223
0x0172: "U", \
224
0x0173: "u", \
225
0x0174: "^W", \
226
0x0175: "^w", \
227
0x0176: "^Y", \
228
0x0177: "^y", \
229
0x0178: "Y", \
230
0x0179: "'Z", \
231
0x017A: "'z", \
232
0x017B: "Z", \
233
0x017C: "z", \
234
0x017D: "Z", \
235
0x017E: "z", \
236
0x017F: "s", \
237
0x018F: "_", \
238
0x0192: "f", \
239
0x01C4: "DZ", \
240
0x01C5: "DZ", \
241
0x01C6: "DZ", \
242
0x01C7: "LJ", \
243
0x01C8: "Lj", \
244
0x01C9: "lj", \
245
0x01CA: "NJ", \
246
0x01CB: "Nj", \
247
0x01CC: "nj", \
248
0x01F1: "DZ", \
249
0x01F2: "Dz", \
250
0x01F3: "dz", \
251
0x0218: "S", \
252
0x0219: "s", \
253
0x021A: "T", \
254
0x021B: "t", \
255
0x0259: "_", \
256
0x20AC: "EUR" }
257
258
def legacyEncode(string):
259
string2 = ""
260
for z, char in enumerate(string.decode("utf-8")):
261
i = ord(char)
262
if i < 33:
263
string2 += "_"
264
elif i in ASCIItranslit:
265
string2 += ASCIItranslit[i]
266
else:
267
try:
268
string2 += char.encode('ascii', 'strict')
269
except:
270
string2 += "_"
271
return string2.upper()