Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100446
| From | eryk sun <eryksun@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: cannot open file with non-ASCII filename |
| Date | 2015-12-14 21:20 -0600 |
| Message-ID | <mailman.10.1450149661.22044.python-list@python.org> (permalink) |
| References | (1 earlier) <566F0BD0.8020106@udel.edu> <mailman.15.1450119109.14916.python-list@python.org> <n4nepp$4nb$1@news2.informatik.uni-stuttgart.de> <4412672.gUIyRlH8Kf@PointedEars.de> <201512150007.tBF07nMo021611@fido.openend.se> |
On Mon, Dec 14, 2015 at 6:07 PM, Laura Creighton <lac@openend.se> wrote: > In a message of Mon, 14 Dec 2015 23:41:21 +0100, "Thomas 'PointedEars' Lahn" wr > ites: > >>Why do you have to use msvcrt? >> >>I would use curses for user input, but: >> >>,-<https://docs.python.org/2/howto/curses.html?highlight=user%20input> >>,-<https://docs.python.org/3.2/howto/curses.html?highlight=user%20input> >>| >>| No one has made a Windows port of the curses module. On a Windows >>| platform, try the Console module written by Fredrik Lundh. The Console >>| module provides cursor-addressable text output, plus full support for >>| mouse and keyboard input, and is available from >>| http://effbot.org/zone/console-index.htm. >> >>So you should try that instead. > > If going for curses, I'd try this instead: > http://pdcurses.sourceforge.net/ Christoph Gohlke has an extension module based on PDCurses [1]. The good news for Python 3 users is that it uses the [W]ide-character console API, such as ReadConsoleInputW. Also, its _get_key_count [2] function is designed to support the alt numpad event sequences that the system creates for the input filepath when dragging a file into the console. In my limited testing, dragging filepaths from Explorer worked without a hitch using a random Latin-1 name "¨°¸ÀÈÐØàèðø" and a Latin Extended-B name "ƠƨưƸǀLjǐǘǠǨǰǸ". Unfortunately the Python 2.7 version is linked against the [A]NSI API, which maps each Unicode character to either the closest matching character in the console's codepage or "?". Moreover the PDCurses code has a bug in narrow builds in that it returns the UnicodeChar from the KEY_EVENT_RECORD [3] instead of the AsciiChar (the name is a misnomer). In this case the high byte is junk. You can mask it out using a bitwise & with 0xFF. That said, IIRC, the OP wants to avoid using any frameworks such as curses or a GUI toolkit. [1]: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses [2]: https://github.com/wmcbrine/PDCurses/blob/PDCurses_3_4/win32/pdckbd.c#L259 [3]: https://msdn.microsoft.com/en-us/library/ms684166
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
cannot open file with non-ASCII filename Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-14 16:24 +0000
Re: cannot open file with non-ASCII filename Terry Reedy <tjreedy@udel.edu> - 2015-12-14 13:34 -0500
Re: cannot open file with non-ASCII filename wxjmfauth@gmail.com - 2015-12-14 11:07 -0800
Re: cannot open file with non-ASCII filename eryk sun <eryksun@gmail.com> - 2015-12-14 12:45 -0600
Re: cannot open file with non-ASCII filename Laura Creighton <lac@openend.se> - 2015-12-14 19:51 +0100
Re: cannot open file with non-ASCII filename Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-14 22:11 +0000
Re: cannot open file with non-ASCII filename Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-14 23:41 +0100
Re: cannot open file with non-ASCII filename Laura Creighton <lac@openend.se> - 2015-12-15 01:07 +0100
Re: cannot open file with non-ASCII filename eryk sun <eryksun@gmail.com> - 2015-12-14 21:20 -0600
Re: cannot open file with non-ASCII filename eryk sun <eryksun@gmail.com> - 2015-12-14 17:55 -0600
Re: cannot open file with non-ASCII filename Laura Creighton <lac@openend.se> - 2015-12-15 01:13 +0100
Re: cannot open file with non-ASCII filename Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-15 08:26 +0000
Re: cannot open file with non-ASCII filename Laura Creighton <lac@openend.se> - 2015-12-15 15:09 +0100
Re: cannot open file with non-ASCII filename eryk sun <eryksun@gmail.com> - 2015-12-15 09:34 -0600
Re: cannot open file with non-ASCII filename Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-12-15 17:04 +0000
Re: cannot open file with non-ASCII filename eryk sun <eryksun@gmail.com> - 2015-12-16 21:39 -0600
Re: cannot open file with non-ASCII filename smap <askme.first@thankyouverymuch.invalid> - 2015-12-18 21:15 +0000
cannot open file with non-ASCII filename bearmingo <bearmingo@gmail.com> - 2015-12-17 21:12 -0800
Re: cannot open file with non-ASCII filename Terry Reedy <tjreedy@udel.edu> - 2015-12-18 01:37 -0500
csiph-web