Commit 7a5e4097 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

if the input is not str but unicode, convert it to str, otherwise...

if the input is not str but unicode, convert it to str, otherwise UnicodeEncodeError can be raised by exporting Page Template containing non-ASCII characters.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28750 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5844fe5f
...@@ -45,6 +45,9 @@ def convert(S, find=None): ...@@ -45,6 +45,9 @@ def convert(S, find=None):
### [\x00-\x1f] characters will be escaped to make a more ### [\x00-\x1f] characters will be escaped to make a more
### readable output. ### readable output.
try: try:
if isinstance(S, unicode):
S = S.encode('utf8')
else:
S.decode('utf8') S.decode('utf8')
except UnicodeDecodeError: except UnicodeDecodeError:
new = ''.join([reprs3.get(x) for x in S]) new = ''.join([reprs3.get(x) for x in S])
......
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