I know there are many questions out there already concerning encoding/decoding. But this is driving me nuts and I'm in desperate need of some help.
I read in a file converting the lines to unicode
line = unicode(line,'latin-1')
Then, I do some mutations and try to write the contents back to a file, encoding the string like this
o_str = '%s,%s' % (new_sname, loc )
w_out.write(o_str.encode('latin-1'))
The file contains for instance the city name 'Genève' which is u'Gen\xc3\xa8ve'
as unicode. Encoding it as 'Latin-1'
gue = gu.encode('iso-8859-1')
gives me on the console
>>> print gue
Genève
But in file my file it still is 'Genève'. Can somebody point me to what I am missing?