Decode bytes (represented as an integer between 0 and 255) to characters in the specified encoding.
(byte_list, encoding="utf-8")
| 139 | |
| 140 | |
| 141 | def bytes_to_chars(byte_list, encoding="utf-8"): |
| 142 | """ |
| 143 | Decode bytes (represented as an integer between 0 and 255) to characters in |
| 144 | the specified encoding. |
| 145 | """ |
| 146 | hex_array = [hex(a).replace("0x", "") for a in byte_list] |
| 147 | hex_array = " ".join([h if len(h) > 1 else f"0{h}" for h in hex_array]) |
| 148 | return bytearray.fromhex(hex_array).decode(encoding) |
| 149 | |
| 150 | |
| 151 | def tokenize_chars(line, lowercase=True, filter_punctuation=True, **kwargs): |
no test coverage detected