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:
Mika Bostrom 2010-01-21 21:23:13 +02:00
parent 34bf2bd8e9
commit e915b0b62c

View File

@ -24,11 +24,18 @@ import Configuration
encoder_to_utf = codecs.lookup('utf-8')
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):
if not_needed: return s
(_out, _len) = encoder_to_utf.encode(s)
return _out
def to_gui(s):
if not_needed: return s
(_out, _len) = encoder_to_sys.encode(s)
return _out