Wrong unicode characters representation in Python 3.4 and py2exe-3 -


I have a problem with the Unicode string in the frozen app. I use Python 3.4.1 32bit (Windows 7 64bit Pro) and I can display it with the following code:

  #! / Usr / bin / python3 # - * - coding: UTF-8 - * - # file: test_py2exe.py import SYS my_string = u "" "This is a test: end of ABC exam ..." "file name = 'Test.txt' if the gateetter (system, 'frozen', fail): file name = 'test-frozen.txt' f = open (file name (Py test_py2exe.py) If I open a standard python (py test_py2exe.py) , The second line in Test.txt is like this (true):  

ábc

If I

 py -3.4 -m To run Pyroxe.build_exe test_py2exe.py  and 'dist \ test_py2exe.exe' with frozen apps, I have such a kind Test-FrozenTax is the second row:  

Ăbc

This problem is not related to simply storing wires to file, but when I use Unicode string With the use of other modules (for example, PEext 5, XLSORIeter), the following instructions are not helpful ... Is this a solution?

I have found that production scripts and frozen apps Switch to the same result: my_string.encode ( 'cp1250'). Decode ('utf-8') . Then the updated code will look like this:

 #! / Usr / bin / python3 # - * - coding: UTF-8 - * - import import system my_string = u "" "This is a test: termination of exam ..." "file name = 'test.txt' Sys_enc = sys.getdefaultencoding () # 'utf-8' locale_enc = locale.getpreferredcoding () # 'cp1250' If the gateetter (system, 'Frozen' false): file name = 'test-frozen.txt' my_string = my_string.encode (Locale_enc) .decode (sys_enc) f = open (file name, mode = 'w', encoding = sys_enc) f.write (my_string) f.close () 

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -