Returns the given value as a Unicode string (if possible).
(v, encoding="utf-8")
| 60 | # assigned to these code points. |
| 61 | |
| 62 | def decode_string(v, encoding="utf-8"): |
| 63 | """ Returns the given value as a Unicode string (if possible). |
| 64 | """ |
| 65 | if isinstance(encoding, basestring): |
| 66 | encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) |
| 67 | if isinstance(v, str): |
| 68 | for e in encoding: |
| 69 | try: return v.decode(*e) |
| 70 | except: |
| 71 | pass |
| 72 | return v |
| 73 | return unicode(v) |
| 74 | |
| 75 | def encode_string(v, encoding="utf-8"): |
| 76 | """ Returns the given value as a Python byte string (if possible). |
nothing calls this directly
no test coverage detected
searching dependent graphs…