Force wmldata.py to print utf-8, so it doesn't crash when encountering it.

If your terminal does not support utf-8 though, this will make a big mess.
This commit is contained in:
Alexander van Gessel 2008-09-19 14:08:14 +01:00
parent f12c0968d2
commit cbf33ca109

View File

@ -14,6 +14,7 @@ not allow composed strings like above.
import re, sys
import wmlparser
import codecs
class Data:
"""Common subclass."""
@ -34,7 +35,9 @@ class Data:
if show_contents:
result += "'" + self.get_value() + "'"
if write:
sys.stdout.write(result + "\n")
# The below is a pretty ugly hack forcing python to accept utf-8
# If your terminal can't handle utf-8, you'll obviously get a big mess (but otherwise you'd get a crash)
codecs.getwriter('utf-8')(sys.stdout).write(result + "\n")
else: return result