I'm facing problems when trying to convert a UTF-8 file (containing Russian characters) into an ISO-8859-5 file: 'charmap' codec can't encode character u'\ufeff' in position 0: character maps to . Has anyone got an idea of what's wrong(?) given the following:
def convert():
try:
import codecs
data = codecs.open('in.txt', 'r', 'utf-8').read()
except Exception, e:
print e
sys.exit(1)
f = open('out.txt', 'w')
try:
f.write(data.encode('iso-8859-5'))
except Exception, e:
print e
finally:
f.close()
"in.txt": ё!—№%«»(эюпоиуыяафйклж;нцхз