xxxxxxxxxx
# UTF-8 encoded string
encoded_str = b'\xe2\x9c\x94\xe2\x9c\x94\xe2\x9c\x94'
# Decoding the UTF-8 encoded string
decoded_str = encoded_str.decode('utf-8')
print(decoded_str)
xxxxxxxxxx
import codecs
BLOCKSIZE = 1048576 # or some other, desired size in bytes
with codecs.open(sourceFileName, "r", "your-source-encoding") as sourceFile:
with codecs.open(targetFileName, "w", "utf-8") as targetFile:
while True:
contents = sourceFile.read(BLOCKSIZE)
if not contents:
break
targetFile.write(contents)
xxxxxxxxxx
# Assuming the string to be decoded is stored in a variable named 'encoded_string'
decoded_string = encoded_string.decode('utf-8')
print(decoded_string)