Catch character encoding errors
This commit is contained in:
parent
a841603460
commit
dda00b6b10
|
@ -31,11 +31,21 @@ if Configuration.LOCALE_ENCODING == 'utf-8':
|
||||||
|
|
||||||
def to_utf8(s):
|
def to_utf8(s):
|
||||||
if not_needed: return s
|
if not_needed: return s
|
||||||
|
|
||||||
|
try:
|
||||||
(_out, _len) = encoder_to_utf.encode(s)
|
(_out, _len) = encoder_to_utf.encode(s)
|
||||||
return _out
|
return _out
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
print 'Could not convert: "%s"' % s
|
||||||
|
raise
|
||||||
|
|
||||||
def to_gui(s):
|
def to_gui(s):
|
||||||
if not_needed: return s
|
if not_needed: return s
|
||||||
|
|
||||||
|
try:
|
||||||
(_out, _len) = encoder_to_sys.encode(s)
|
(_out, _len) = encoder_to_sys.encode(s)
|
||||||
return _out
|
return _out
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
print 'Could not convert: "%s"' % s
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user