Kaydet (Commit) e99b97e5 authored tarafından Fred Drake's avatar Fred Drake

encode(): Handle Latin-1 input characters better.

üst bda05564
...@@ -35,15 +35,19 @@ def decode(s): ...@@ -35,15 +35,19 @@ def decode(s):
_charmap = {} _charmap = {}
for c in map(chr, range(256)): for c in range(128):
_charmap[c] = c _charmap[chr(c)] = chr(c)
_charmap[unichr(c + 128)] = chr(c + 128)
_charmap["\n"] = r"\n" _charmap["\n"] = r"\n"
_charmap["\\"] = r"\\" _charmap["\\"] = r"\\"
del c del c
_null_join = ''.join _null_join = ''.join
def encode(s): def encode(s):
return _null_join(map(_charmap.get, s)) try:
return _null_join(map(_charmap.get, s))
except TypeError:
raise Exception("could not encode %r: %r" % (s, map(_charmap.get, s)))
class ESISReader(xml.sax.xmlreader.XMLReader): class ESISReader(xml.sax.xmlreader.XMLReader):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment