Polish characters in utf-8 change after being saved to a textfile

476 Views Asked by At

The character "\xc4\x86" represents letter "Ć" but after executing this code:

string = "ABC\xc4\x86def"

with open("messagessemi.txt","w", encoding = "utf-8") as f:
    f.write(string)

the content of messagessemi.txt looks like this:

ABCĆdef

What should I do to save the letters in a correct way? Thank you for any clues.

0

There are 0 best solutions below