The rule for Unicode is same encoding all the way in and out.
So for Python 2.x use codecs or newer io,Python 3.x has this build in.
Set utf-8 in first line,Python 2.x has ASCII as default encoding.
Then it look like this.
Test input iso.txt: Déjà vu peut-être...
So for Python 2.x use codecs or newer io,Python 3.x has this build in.
Set utf-8 in first line,Python 2.x has ASCII as default encoding.
Then it look like this.
Test input iso.txt: Déjà vu peut-être...
# -*- coding: utf-8 -*- import codecs with codecs.open("iso.txt", encoding='utf-8') as f: uni = f.read() with codecs.open("iso_out.txt", 'w', encoding='utf-8') as f_out: f_out.write(uni)iso_out.txt:
Output:Déjà vu peut-être...