gettextify charset
This commit is contained in:
parent
3486320b6a
commit
80d00dbde6
|
@ -42,10 +42,10 @@ def to_utf8(s):
|
||||||
_out = unicode(s, Configuration.LOCALE_ENCODING).encode('utf-8')
|
_out = unicode(s, Configuration.LOCALE_ENCODING).encode('utf-8')
|
||||||
return _out
|
return _out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
sys.stderr.write(_('Could not convert: "%s"\n') % s)
|
||||||
raise
|
raise
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
sys.stderr.write('Could not encode: "%s"\n' % s)
|
sys.stderr.write(_('Could not encode: "%s"\n') % s)
|
||||||
raise
|
raise
|
||||||
except TypeError: # TypeError is raised when we give unicode() an already encoded string
|
except TypeError: # TypeError is raised when we give unicode() an already encoded string
|
||||||
return s
|
return s
|
||||||
|
@ -57,10 +57,10 @@ def to_db_utf8(s):
|
||||||
(_out, _len) = encoder_to_utf.encode(unicode(s))
|
(_out, _len) = encoder_to_utf.encode(unicode(s))
|
||||||
return _out
|
return _out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
sys.stderr.write(_('Could not convert: "%s"\n') % s)
|
||||||
raise
|
raise
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
sys.stderr.write('Could not encode: "%s"\n' % s)
|
sys.stderr.write(_('Could not encode: "%s"\n') % s)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def to_gui(s):
|
def to_gui(s):
|
||||||
|
@ -72,10 +72,10 @@ def to_gui(s):
|
||||||
(_out, _len) = encoder_to_sys.encode(s, 'replace')
|
(_out, _len) = encoder_to_sys.encode(s, 'replace')
|
||||||
return _out
|
return _out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
sys.stderr.write(_('Could not convert: "%s"\n') % s)
|
||||||
raise
|
raise
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
sys.stderr.write('Could not encode: "%s"\n' % s)
|
sys.stderr.write(_('Could not encode: "%s"\n') % s)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def to_hex(s):
|
def to_hex(s):
|
||||||
|
@ -83,7 +83,7 @@ def to_hex(s):
|
||||||
out = coder_hex.encode(s)[0]
|
out = coder_hex.encode(s)[0]
|
||||||
return out
|
return out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
sys.stderr.write(_('Could not convert: "%s"\n') % s)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def from_hex(s):
|
def from_hex(s):
|
||||||
|
@ -91,5 +91,5 @@ def from_hex(s):
|
||||||
out = coder_hex.decode(s)[0]
|
out = coder_hex.decode(s)[0]
|
||||||
return out
|
return out
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
sys.stderr.write(_('Could not convert: "%s"\n') % s)
|
||||||
return s
|
return s
|
||||||
|
|
Loading…
Reference in New Issue
Block a user