Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107275
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Convert input to upper case on screen as it is typed |
| Date | 2016-04-19 05:11 +1000 |
| Message-ID | <mailman.155.1461006711.6324.python-list@python.org> (permalink) |
| References | (1 earlier) <mailman.90.1460604334.15650.python-list@python.org> <nen5jj$hvi$1@dont-email.me> <85bn5cy6bz.fsf@benfinney.id.au> <8537qoy49y.fsf@benfinney.id.au> <85zisqratt.fsf@benfinney.id.au> |
Ben Finney <ben+python@benfinney.id.au> writes:
> Ben Finney <ben+python@benfinney.id.au> writes:
>
> > Okay, ‘termios.tcgetattr’ will let me preserve the attributes, and
> > with Dan Sommers's suggestion of which attribute to use, I may have
> > a shot at setting the terminal attributes.
>
> This works!
Except, it doesn't. As designed and documented in the Single Unix
Specification <URL:http://pubs.opengroup.org/onlinepubs/7908799/>,
the behaviour of the OLCUC feature is:
OLCUC Map lower case to upper on output. (LEGACY)
<URL:http://pubs.opengroup.org/onlinepubs/7908799/xbd/termios.html>
That ominous “LEGACY” annotation is applied, notably, to all the
case-conversion features of ‘termios’.
The mapping is ignorant of Unicode, ignorant of ANSI escape sequences;
it blindly converts bytes via a mapping that assumes all bytes are ASCII
text, regardless of whether those bytes actually represent text.
It breaks the “visual bell” feature, among others. I end up with garbage
on the screen, that would otherwise have been Unicode text or useful
control sequences.
> I had been hoping that I could simply wrap some stream in a simple
> “convert what they actually type so it's upper case” text codec,
> without fiddling at such a low operating-system specific level. This
> is rather more esoteric than I had hoped.
And, it turns out, doesn't address the requirements without causing more
problems.
I am still looking for a solution (a Python-specific one would be fine).
--
\ “Anything that we scientists can do to weaken the hold of |
`\ religion should be done and may in the end be our greatest |
_o__) contribution to civilization.” —Steven Weinberg |
Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 13:25 +1000
Re: Convert input to upper case on screen as it is typed Dan Sommers <dan@tombstonezero.net> - 2016-04-14 04:16 +0000
Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 15:17 +1000
Re: Convert input to upper case on screen as it is typed Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-14 18:35 +1200
Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 17:53 +1000
Re: Convert input to upper case on screen as it is typed Steven D'Aprano <steve@pearwood.info> - 2016-04-14 21:43 +1000
Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-14 18:37 +1000
Re: Convert input to upper case on screen as it is typed Marko Rauhamaa <marko@pacujo.net> - 2016-04-14 12:22 +0300
Re: Convert input to upper case on screen as it is typed Chris Angelico <rosuav@gmail.com> - 2016-04-14 18:45 +1000
Re: Convert input to upper case on screen as it is typed Ben Finney <ben+python@benfinney.id.au> - 2016-04-19 05:11 +1000
Re: Convert input to upper case on screen as it is typed Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-19 17:46 +1200
csiph-web