I have problem with Unicode strings in frozen app. I use python 3.4.1 32bit (on Windows 7 64bit Pro) and py2exe-3 from svn repository. I can demonstrate it with following code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# file: test_py2exe.py
import sys
my_string = u"""This is a test:
ábc
End of test..."""
filename = 'test.txt'
if getattr(sys, 'frozen', False):
filename = 'test-frozen.txt'
f = open(filename, mode='w', encoding='utf-8')
f.write(my_string)
f.close()
If I run in standard python shell (py test_py2exe.py) the second line in test.txt is like this (correct):
ábc
If I create frozen app with
py -3.4 -m py2exe.build_exe test_py2exe.pyand run 'dist\test_py2exe.exe' I have in test-frozen.txt second line like this:
ábc
This problem is not related to storing strings to file only, but also when I use other modules (e.g. PyQt5, xlsxwriter) with unicode strings. Following instruction on EvenMoreEncodings does not help... Is there any solution for this?