Commit 03d737fc authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

patches/ppml: always use base64 encoding for non-utf8 string.

in most cases, where ASCII-range characters are less than 80% of input
non-utf8 string, the result is same but we can reduce needless string
replacement calls. in rare case, for example wrongly iso-8859-1
encoded properties or PDF data, the result becomes different, i.e.
before: ASCII-range characters + escaped characters => after: base64
encoding, but the meaning is still same.
parent a65d8425
...@@ -53,7 +53,7 @@ def convert(S): ...@@ -53,7 +53,7 @@ def convert(S):
if not isinstance(S, unicode): if not isinstance(S, unicode):
S.decode('utf8') S.decode('utf8')
except UnicodeDecodeError: except UnicodeDecodeError:
new = ''.join([reprs3.get(x) for x in S]) return 'base64', base64.encodestring(S)[:-1]
else: else:
new = ''.join([reprs.get(x, x) for x in S]) new = ''.join([reprs.get(x, x) for x in S])
### patch end ### patch end
......
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