Reputation: 9
I built an encryption method that turns plaintext into Hebrew, and I am trying to write the Hebrew to a text file using Python, and I've run across the following issue:
The Hebrew text writes properly in the shell, however once I write it to a text file, this is what is written:
ää0ä0ãçççâäää0àããåäääãçååãàáÌáÌ0
I am using Python's standard encoding cp1255 to write to my text file. Is there an issue with Python writing to the file, or is it the file itself?
Upvotes: 1
Views: 100
Reputation: 842
I don't know if you're using python 3.
Check this out here: https://docs.python.org/3/howto/unicode.html .
Moreover, you should use UTF-8 to encode your unicode. CP1255 has only Hebrew in it https://en.wikipedia.org/wiki/Windows-1255
Your console should support unicode, which is why you see it properly there.
Basically, what I'm saying is: If you use Python 3 and use no shenanigan at all, it should work by default :-)
If you force an old encoding... then you'll get down the rabbit hole...
Upvotes: 1