0

Can anyone explain to me why the encoding goes wrong? I've been trying to find an answer and most point to the encoding used by the program that is used to read the output. I'm sure that its not the encoding for the TextEdit (its the program that is opening the text file). Can anyone shed some light on this for me?

Update: When I select all and copy paste to a new text file, TextEdit tells me to re-save the file in utf-8 encoding. Although this doesn't solve the problem it is a workaround; although now it seems the the default encoding isn't utf-8 for TextEdit even though I have already set utf-8 to be the default encoding.

YellowPillow
  • 3,000
  • 3
  • 25
  • 50

1 Answers1

0

You may need to encode the text before writing to a text file. You posted no code, but it'd be something like f.write(out_text_variable.encode('utf8')) instead of f.write(out_text_variable).

Then, your text editor will properly decode it when viewing.

FTA
  • 305
  • 1
  • 7
  • Ahh alright I think I can figure it out from there. – YellowPillow Jul 14 '15 at 21:18
  • http://stackoverflow.com/questions/15092437/python-encoding-utf-8, actually I believe that I have already encoded it in utf8 so it doesn't seem to be the solution. This is because I got the same error as the person. – YellowPillow Jul 14 '15 at 21:21