473,326 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Getting strange characters in the command prompt

For information, I have windows xp (english edition).

When I use special non-english characters (like é à è ...) in my
python code, IDLE tells me to add a line like:

# -*- coding: cp1252 -*-

.... because of the presence of non-ASCII characters.

When I write a script like the folowing:

# -*- coding: cp1252 -*-
print "é à è"

.... and I run it in the windows command prompt, I get strange
characters I didn't ask for.

And when I write those non-English characters (é à è) directly in the
command prompt, I get the correct characters.

Can anyone help we with that problem?
Jul 18 '05 #1
3 2864
sebb wrote:

[...]
... and I run it in the windows command prompt, I get strange
characters I didn't ask for.

And when I write those non-English characters (é à è) directly in the
command prompt, I get the correct characters.

Can anyone help we with that problem?


Does executing

chcp 1252

before running your python program help?
The windows console is not set to code page 1252 by default
as far as I know, but some other windows-specific encoding.

--Irmen
Jul 18 '05 #2
sebb wrote:
# -*- coding: cp1252 -*-
print "é à è"

... and I run it in the windows command prompt, I get strange
characters I didn't ask for.
[...] Can anyone help we with that problem?


As Irmen explains, this is because cmd.exe uses code page 850
(on your installation). You should write

print u"é à è"

Regards,
Martin

Jul 18 '05 #3
Thanks a lot
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Funduk | last post by:
Hello, So I've been playing with Python and Pygame for a while and I decided I wanted to make a real executable so I could send that stuff over to my friends to show off my <sarcasm>maad...
11
by: Marian Aldenhövel | last post by:
Hi, I am very new to Python and have run into the following problem. If I do something like dir = os.listdir(somepath) for d in dir: print d The program fails for filenames that contain...
4
by: 21novembre | last post by:
Hi all, I got a quite strange problem when I tried to setup a database backup shell. I put it this way: "bin/mysqldump --opt --user=xxx --password=xxx DB > DB.bak" However, error 1045 came to...
8
by: Victor Lamberty | last post by:
Greetings C coders I am new to the world of C and have been trying to compile this program. I got the result that I wanted but outputed it in a strange way it put it before the prompt is there a...
9
by: Jon Davis | last post by:
I have a problem with encoding, I think (??). I have the following code: StreamWriter sw = File.CreateText(l); sw.Write(data); sw.Close(); Now, "data" is a string that contains text, but...
4
by: glenn | last post by:
I keep reading all sorts of books on VS that keep telling me to click on Tools/Visual Studio Command prompt to run this program or that program. However, I do not have such a menu choice. Where is...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
1
by: emma_middlebrook | last post by:
Hi If I'm developing a console application, I'd rather not have to go to the project settings and edit the command line arguments each time and then run. Is there a way I can get a console...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.