Windows NT shell + extended characters. Bug or what?

Bengt Richter bokr at oz.net
Fri Mar 15 15:55:10 EST 2002


On 15 Mar 2002 03:19:20 -0800, nsbase at yahoo.co.uk (Noel Smith) wrote:

>I've been recently using the Python shell on Linux as a handy way to
>get character numbers from various extended LATIN-1 characters.
>
>i.e. For UK pound and Yen currency signs:
>
>>>> print ord('£')
>163
>>>> print ord('¥')
>165
>
>Which are the correct values.
>
>However I've recently installed python 7.2 on Windows NT4 and found it
>gives the following results when using the command line shell:
>
>>>> print ord('£')
>156
>>>> print ord('¥')
>157
>
>Which is clearly wrong although strangely enough when I type the same
>thing into IDLE on Windows NT, it produces the correct results.
>
>Is this a bug or is there some windows character mapping going on
>behind the scenes which I've missed out? Is there any configuration
>that I've missed out?
>
The console version is using ascii, and IDLE is probably using
Courier new 10 point with latin-1 encoding.

You can edit \Python2x\Tools\idle\config-win.txt (x>=1?) and change the
font name to "terminal" and that will make idle close to the console font,
but not exactly. The encoding has to change from latin-1 (?) to "Windows Characters"
to get all the '\x80' to '\x9f' characters.
I don't know how to control python's output encoding to select "windows characters"

To see the characters in question, try this in the console window vs IDLE.
 >>> 
 print ''.join([chr(c) for c in xrange(0x80,0x9f+1)])
 ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥Pƒ

(That's pasted from the console window with whatever encoding conversion
windows and my news reader may be doing).

 >>> print ''.join([chr(c) for c in xrange(0x80,0x9f+1)])
 €???????????Ž????????????ž?

(That's from IDLE with terminal font, copied and pasted. The boxes are
where the characters show up as on console, with the ??'s showing where characters
are left out because the encoding is still latin-1, not "windows characters".

Maybe there is an terminal font to show ascii for latin-1 encoding somewhere?

>Any help would be really appreciated.
>
I guess the problem is being worked on.

Regards,
Bengt Richter




More information about the Python-list mailing list