Q:

Trying to use output.write with UTF-8 str and get's an error (python 3.x)

I'm using the following code to print (to file) UTF-8 str :
output.write(currentWord.m_wordHeb)

tried also :
output.write(currentWord.m_wordHeb.encode('utf-8')

and also added :
import sys
import codecs

sys.stdout = codecs.getwriter('utf8')(sys.stdout)

keeps getting errors ... 
usually this one :
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined>

Thank you !

A:

Problem was solved, the file i opened for writing wasn't opened as it should for utf-8.
So when i changed the 'open command' to the following : 
codecs.open("C:\\NLP\\output.txt", "w", "utf-8" )

everything seems to work out.
Thank you !

