Source Code:
(back to article)
# Encode a string in UTF-8 string = "Hello, 世界" encoded_string = string.encode("utf-8") print(encoded_string) # b'Hello, \xe4\xb8\x96\xe7\x95\x8c' # Decode a UTF-8 encoded string decoded_string = encoded_string.decode("utf-8") print(decoded_string) # 'Hello, 世界'
Result:
Report an issue