Hi Guys,

I was hoping someone can help me with this. I have a python program that reads and writes files in utf-8(unicode). When I run it in Eclipse, the output is perfectly fine. When I try making an exe file of my program it is not working. I also tried double clicking the python program to run it in windows dos but the same problem occurred. I tried running it in pythonWin still the same problem. Now I have a problem debugging my program since it is working perfectly fine in Eclipse. Is it a problem about encoding? I placed this:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

but it doesn't seem to work. hope someone can help me with this. I am reading and writing files in xml with utf-8/unicode characters

And what code page have you set up for the windows dos? I found CHCP 1252 works best for me, before I thought I had to live with code page 850 or 437, but fortunately it is not true.

I have not tried how well the code page chcp 65001 (UTF-8) works yet though.

Edited 6 Years Ago by pyTony: n/a

Hi! How do you set the codepage for dos? If i do this will my program run when I make an exe file and use it using other's pc? My program is to read and write in xml. I need to look for characters that is not converted to their xml/html entities. It's now difficult to debug my program since it is doing fine in eclipse but not in dos or in exe. Do I need to write something at the top of my program to make windows read it that it has such encoding?


And what code page have you set up for the windows dos? I found CHCP 1252 works best for me, before I thought I had to live with code page 850 or 437, but fortunately it is not true.

I have not tried how well the code page chcp 65001 (UTF-8) works yet though.

Eclipse has the fonts installed to print the encoding. The command line obviously does not. You can try to change the default font but that is dependent on which distro you are using as well as which terminal program (xterm is -fa font-name).

Edited 6 Years Ago by woooee: n/a

I think encoding of your program to match what CHCP says in command line is enough. Code page 1252 makes scandinavian letter work from command line arguments and show correct in file name for DIR command. However, if I use GNU ls command in windows, those letters are missing. I hope that setting the code page in AUTOEXEC.BAT is enough, but I am not sure. I have only set it by hand and prove now to put there to see if the code page becomes default. If not, must see some windows settings and environment variables.

This article has been dead for over six months. Start a new discussion instead.