At 12:27 PM 12/15/2015, Tim Roberts wrote:
Ulli Horlacher wrote:
> On Tue 2015-12-15 (11:10), Tim Roberts wrote:
>
>>> I have a python 2.7 program which runs in a console window and
upload files.
>>> To specify the files, the user uses Windows drag&drop (via
explorer) or copy&paste.
>> This is hopeless. In addition to the normal difficulties in
>> string/Unicode conversions, you have the added limitations of the
>> current console code page. You simply cannot type characters in a
>> Windows console that are not present in your current code page.
> What is the current code page?
The Windows console shell is an 8-bit entity. That means you only have
256 characters available at any given time, similar to they way
non-Unicode strings work in Python 2. The "code page" determines which
256 you are using. You can type "chcp" to see the current code page.
By default, you get code page 437, which derived from the original IBM
PC character ROMs. You simply cannot type or display characters that
are not in the current code page.
Using msvcrt.getchw does not convert the console to a Unicode entity.
It merely means the characters you DO get are represented in Unicode.
The Windows console theoretically supports a UTF-8 code page (chcp
65001), and it does fix many of these problems, but there are some
console apps that won't like it.
It is 16 bits per character
There may be some confusion in that each code page is 256 codes
https://msdn.microsoft.com/en-us/library/ms686013%28v=vs.85%29.aspx
but pages can be switched at will
Windows chcp
https://technet.microsoft.com/en-us/library/bb490874.aspx
good discussion
http://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html
My Win 7 console is US default 437
https://msdn.microsoft.com/en-us/library/dd317756%28v=vs.85%29.aspx
https://en.wikipedia.org/wiki/Win32_console#Windows_NT_and_Windows_CE
- Ray
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32