root/scripts/lib/strings.py @ 79
1 | 73 | aaronmk | # String manipulation
|
---|---|---|---|
2 | |||
3 | def to_unicode(str_): |
||
4 | if isinstance(str_, unicode): return str_ |
||
5 | encodings = ['utf_8', 'latin_1'] |
||
6 | for encoding in encodings: |
||
7 | try: return unicode(str_, encoding) |
||
8 | except UnicodeDecodeError, e: pass |
||
9 | raise AssertionError(encoding+' is not a catch-all encoding') |