(value, from_enc=DEFAULT_ENCODING)
| 43 | |
| 44 | |
| 45 | def to_unicode(value, from_enc=DEFAULT_ENCODING): |
| 46 | if isinstance(value, six.text_type): |
| 47 | return value |
| 48 | if isinstance(value, six.binary_type): |
| 49 | if six.PY2: |
| 50 | return unicode(value, from_enc, ENCODING_ERRORS_POLICY) # noqa |
| 51 | else: |
| 52 | return value.decode(from_enc, errors=ENCODING_ERRORS_POLICY) |
| 53 | return six.text_type(value) |
| 54 | |
| 55 | |
| 56 | # Optional from_enc enables transcoding |
no test coverage detected