-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on unicode character \u00A0 #52
Comments
The important part of the error is: "UnicodeDecodeError: 'ascii' codec can't decode". We need to know why the ascii codec is used for Unicode/UTF-8. If this still is a problem for you, please attach the xml file causing the error. |
It seems I cannot attach an XML file here, but a very simple input file will do already:
I am simply running |
I tested on Python 3 and couldn't reproduce the issue - it just worked. I don't have time to look at this for Python 2. PS! You cant use "\u00a0" inside the XML file, but I just replaced it with an actual non-breaking space. |
I had a similar problem with unicode escapes. I did not get a crash, but instead all strings with unicode escape were being omitted. Based on this thread I installed android2po again using my python3 binaries and the problem went away. |
When using Unicode character \u00A0 (non-breaking whitespace) in a strings.xml, I get the crash below. Anything wrong with my configuration (if there is any) or any quick fix for that?
u'00A0'
u'00A0'
u'00A0'
[failed] locale/strings.pot
Traceback (most recent call last):
File "/usr/local/bin/a2po", line 3, in
android2po.run()
File "/usr/local/lib/python2.7/dist-packages/android2po/program.py", line 227, in run
sys.exit(main(sys.argv) or 0)
File "/usr/local/lib/python2.7/dist-packages/android2po/program.py", line 215, in main
command_result = cmd.execute()
File "/usr/local/lib/python2.7/dist-packages/android2po/commands.py", line 464, in execute
self.generate_templates()
File "/usr/local/lib/python2.7/dist-packages/android2po/commands.py", line 293, in generate_templates
kind, do_write=True, update=update)
File "/usr/local/lib/python2.7/dist-packages/android2po/commands.py", line 264, in make_or_get_template
xmldata = read_xml(action, self.env.default.xml(kind))
File "/usr/local/lib/python2.7/dist-packages/android2po/commands.py", line 63, in read_xml
return convert.read_xml(filename, warnfunc=action.message, **kw)
File "/usr/local/lib/python2.7/dist-packages/android2po/convert.py", line 370, in read_xml
text, formatted = get_element_text(tag, name, warnfunc)
File "/usr/local/lib/python2.7/dist-packages/android2po/convert.py", line 310, in get_element_text
converted_value, elem_formatted = convert_text(t)
File "/usr/local/lib/python2.7/dist-packages/android2po/convert.py", line 242, in convert_text
return "".join(text[:-1]), formatted
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 0: ordinal not in range(128)
The text was updated successfully, but these errors were encountered: