alek-sys / sublimetext_indentxml

Plugin for Sublime Text editor for reindenting XML and JSON files
MIT License
536 stars 134 forks source link

Fail to indent files containing accents #7

Closed MrWaz closed 12 years ago

MrWaz commented 12 years ago

Hi, I'm a french user of Sublime and your marvelous plugin that really helps when dealing with openXML documents. But the plugin fails to deal with files containing accents like "é", etc..

Traceback (most recent call last):
    File ".\sublime_plugin.py", line 282, in run_
    File ".\indentxml.py", line 37, in run
    File ".\indentxml.py", line 45, in indentxml
    File ".\xml\dom\minidom.py", line 1928, in parseString
    File ".\xml\dom\expatbuilder.py", line 940, in parseString
    File ".\xml\dom\expatbuilder.py", line 223, in parseString
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1049: ordinal not in range(128)

I'm not a python expert but checking line 45 in indentxml.py I did a slight change that change my life. pyhton s = parseString(s).toprettyxml() => s = parseString(s.encode( "utf-8" )).toprettyxml()

Don't know if this was a good idea, but a least a suggestion to make your non-english users happy.

All the best Mr Waz

alek-sys commented 12 years ago

Shame on me :) This issue already was raised and fixed but during refactoring I've lost changes. Now it fixed again, just start package upgrade if you are using Package Control.

Alex.

MrWaz commented 12 years ago

Hi Alex

Just noticed a new thing. If I use the command w/o selecting anything, it remove the <?xml version="1.0" encoding="UTF-8" standalone="yes"?> Tag at the beginning of the doc. Isn't that a bit weird?

cheers MrWaz

alek-sys commented 12 years ago

XML declaration issue should already be fixed. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> works ok now.