summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-06-09 16:21:54 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-06-09 16:50:13 +0200
commitbf56250be719dae16808914e681b8f08980546c3 (patch)
tree96252b966fe01dee8adc0620e42e3aa8a0be4d3e
parentfd2ca3c222295bc7b52db6f5edd9a2d911046e81 (diff)
downloadpykolab-bf56250be719dae16808914e681b8f08980546c3.tar.gz
Only non-unicode strings need be decoded
-rw-r--r--pykolab/translit.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/pykolab/translit.py b/pykolab/translit.py
index 855e249..fd27d8f 100644
--- a/pykolab/translit.py
+++ b/pykolab/translit.py
@@ -102,13 +102,22 @@ def transliterate(_input, lang, _output_expected=None):
_output = ''
- for char in _input.decode('utf-8'):
- if translit_map[_translit_name].has_key(char):
- _output += translit_map[_translit_name][char]
- elif char in [repr(x) for x in translit_map[_translit_name].keys()]:
- _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]]
- else:
- _output += char
+ if not isinstance(_input, unicode):
+ for char in _input.decode('utf-8'):
+ if translit_map[_translit_name].has_key(char):
+ _output += translit_map[_translit_name][char]
+ elif char in [repr(x) for x in translit_map[_translit_name].keys()]:
+ _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]]
+ else:
+ _output += char
+ else:
+ for char in _input:
+ if translit_map[_translit_name].has_key(char):
+ _output += translit_map[_translit_name][char]
+ elif char in [repr(x) for x in translit_map[_translit_name].keys()]:
+ _output += translit_map[_translit_name][[char in [raw(x) for x in translit_map[_translit_name].keys()]][0]]
+ else:
+ _output += char
return _output