| changeset 236 | 725653080973 |
| parent 175 | 4f072edc51a1 |
--- a/src/cm/utils/string_utils.py Fri Mar 26 12:19:38 2010 +0100 +++ b/src/cm/utils/string_utils.py Tue Mar 30 14:13:45 2010 +0200 @@ -4,7 +4,11 @@ def to_unicode(input): if type(input) == str: res = None - for encoding in [chardet.detect(input)['encoding'], 'utf8', 'latin1']: + encodings = ['utf8', 'latin1'] + doc_enc = chardet.detect(input)['encoding'] + if doc_enc: + encodings = [doc_enc,] + encodings + for encoding in encodings: try: res = unicode(input, encoding) break;