Allow to bypass codec
If the system (display) locale is UTF-8, there is no need to encode to either direction. In fact, running the .encode() routine appears to mangle a valid UTF-8 string to a worse condition, effectively breaking it.
This commit is contained in:
parent
34bf2bd8e9
commit
e915b0b62c
|
@ -24,11 +24,18 @@ import Configuration
|
||||||
encoder_to_utf = codecs.lookup('utf-8')
|
encoder_to_utf = codecs.lookup('utf-8')
|
||||||
encoder_to_sys = codecs.lookup(Configuration.LOCALE_ENCODING)
|
encoder_to_sys = codecs.lookup(Configuration.LOCALE_ENCODING)
|
||||||
|
|
||||||
|
# I'm saving a few cycles with this one
|
||||||
|
not_needed = False
|
||||||
|
if Configuration.LOCALE_ENCODING == 'utf-8':
|
||||||
|
not_needed = True
|
||||||
|
|
||||||
def to_utf8(s):
|
def to_utf8(s):
|
||||||
|
if not_needed: return s
|
||||||
(_out, _len) = encoder_to_utf.encode(s)
|
(_out, _len) = encoder_to_utf.encode(s)
|
||||||
return _out
|
return _out
|
||||||
|
|
||||||
def to_gui(s):
|
def to_gui(s):
|
||||||
|
if not_needed: return s
|
||||||
(_out, _len) = encoder_to_sys.encode(s)
|
(_out, _len) = encoder_to_sys.encode(s)
|
||||||
return _out
|
return _out
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user