Windows NT shell + extended characters. Bug or what?

Wolfgang Strobl ws at mystrobl.de
Sun Mar 17 08:26:14 EST 2002


16 Mar 2002 01:06:45 +0100, martin at v.loewis.de (Martin v. Loewis):

>"Jason Orendorff" <jason at jorendorff.com> writes:
>
>> Alas, the PC console uses a different character set called CP437,
>> which is not Latin-1 compatible.  In CP437, the pound sign
>> is 156 and the yen sign is 157.
>
>This isn't really true. The console on Windows (I believe both Win9x,
>and NTx) use what MS calls the "OEM" charset. Which code page that is
>depends on the Windows installation. In the US English installation,
>it is indeed CP437. In the European installations, it is CP852 most of
>the time.
 
... or CP850 aka DOS Latin 1.  CP852 is Latin 2

>
>>         [in Win2K console]
>>         >>> ord(u'£')
>>         156    # uhhh, no
>>         >>> ord(u'\N{POUND SIGN}')
>>         163    # correct answer
>> 
>>       I think it's fair to say this is a deficiency in current
>>       versions of Python.  I believe it will be fixed
>
>This is rather unlikely, I doubt the interactive interpreter will ever
>be able to properly identify the encoding of the console window. 

What's wrong with GetConsoleOutputCP, besides the restrictions
documented in "Q99795 SetConsoleOutputCP Only Effective with Unicode
Fonts"? This API function exits since Windows NT 3.1  was released -
i.e. it's almost a year older than Python version 1.0.0.

C:\e\consolecp>type conoutputcp.c
#include <windows.h>
main()
{ printf("Code page %d",GetConsoleOutputCP());}
C:\e\consolecp>

C:\e\consolecp>cl /nologo conoutputcp.c
conoutputcp.c

C:\e\consolecp>conoutputcp.exe
Code page 850
C:\e\consolecp>chcp 1252
Aktive Codepage: 1252.

C:\e\consolecp>conoutputcp.exe
Code page 1252
C:\e\consolecp>python
Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ord(u'£')
163
>>>

-- 
Thank you for observing all safety precautions



More information about the Python-list mailing list