4 |
|
|
5 |
from backwards_compatibility import * |
from backwards_compatibility import * |
6 |
from xml.sax.saxutils import escape |
from xml.sax.saxutils import escape |
7 |
import sys, types |
import sys, types, unicodedata |
8 |
|
|
9 |
_replace='replace' |
_replace='replace' |
10 |
|
|
62 |
psyco.bind(pack_list) |
psyco.bind(pack_list) |
63 |
except: |
except: |
64 |
pass |
pass |
65 |
|
|
66 |
|
def unicode2ascii(unistr): |
67 |
|
l = [] |
68 |
|
for c in unistr: |
69 |
|
d = unicodedata.decomposition(c) |
70 |
|
if d: |
71 |
|
for e in d.split(): |
72 |
|
e = int(e, 16) |
73 |
|
if 65 <= e <= 122: |
74 |
|
l.append(chr(e)) |
75 |
|
else: |
76 |
|
if ord(c) < 128: |
77 |
|
l.append(str(c)) |
78 |
|
return ''.join(l) |