| author | raph |
| Tue, 30 Mar 2010 14:13:45 +0200 | |
| changeset 236 | 725653080973 |
| parent 235 | b23aee4dd81d |
| child 237 | 48c4d74c5cd9 |
--- 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;