Source Code:
(back to article)
def decode_text(text): try: return text.decode('utf-8') except UnicodeDecodeError: return "Invalid continuation byte" invalid_text = b'\x80abc' decoded_text = decode_text(invalid_text) print(decoded_text)
Result:
Report an issue