From e915b0b62cb5abb920580f2cd379c9ca6b29d27d Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Thu, 21 Jan 2010 21:23:13 +0200 Subject: [PATCH] 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. --- pyfpdb/Charset.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyfpdb/Charset.py b/pyfpdb/Charset.py index 2c6f78c3..85cbd69a 100644 --- a/pyfpdb/Charset.py +++ b/pyfpdb/Charset.py @@ -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