Decode bytes from binary input streams. Defaults to decoding from 'latin1'. That differs from the behavior of np.compat.asunicode that decodes from 'ascii'. Parameters ---------- line : str or bytes Line to be decoded. encoding : str Encoding used to decod
(line, encoding=None)
| 9 | |
| 10 | |
| 11 | def _decode_line(line, encoding=None): |
| 12 | """Decode bytes from binary input streams. |
| 13 | |
| 14 | Defaults to decoding from 'latin1'. That differs from the behavior of |
| 15 | np.compat.asunicode that decodes from 'ascii'. |
| 16 | |
| 17 | Parameters |
| 18 | ---------- |
| 19 | line : str or bytes |
| 20 | Line to be decoded. |
| 21 | encoding : str |
| 22 | Encoding used to decode `line`. |
| 23 | |
| 24 | Returns |
| 25 | ------- |
| 26 | decoded_line : str |
| 27 | |
| 28 | """ |
| 29 | if type(line) is bytes: |
| 30 | if encoding is None: |
| 31 | encoding = "latin1" |
| 32 | line = line.decode(encoding) |
| 33 | |
| 34 | return line |
| 35 | |
| 36 | |
| 37 | def _is_string_like(obj): |
no test coverage detected