Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107275

Re: Convert input to upper case on screen as it is typed

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
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 Tue, 19 Apr 2016 05:11:42 +1000
Lines 45
Message-ID <mailman.155.1461006711.6324.python-list@python.org> (permalink)
References <85oa9cyiqt.fsf@benfinney.id.au> <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>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de UrT1gyHupW6TqzunQNxn1QyfyaEAV3HIG2ppTiiMeIpw==
Cancel-Lock sha1:gu4WpH/1KiSVNKrPi0L02hupWwA=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'converts': 0.07; 'escape': 0.07; 'sequences.': 0.07; 'garbage': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unicode,': 0.09; 'causing': 0.13; '(legacy)': 0.16; '8bit%:26': 0.16; 'attributes,': 0.16; 'attributes.': 0.16; 'blindly': 0.16; 'fine).': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'scientists': 0.16; 'screen,': 0.16; 'subject:Convert': 0.16; 'subject:case': 0.16; 'subject:screen': 0.16; 'attribute': 0.18; 'bytes': 0.18; 'documented': 0.18; 'ascii': 0.22; 'assumes': 0.22; 'text,': 0.22; 'unix': 0.24; 'feature': 0.24; 'header:User- Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'turns': 0.27; 'ansi': 0.29; 'behaviour': 0.29; 'dan': 0.29; 'feature,': 0.29; 'preserve': 0.29; 'regardless': 0.31; 'useful': 0.33; 'stream': 0.33; 'wrap': 0.33; 'requirements': 0.35; 'could': 0.35; 'text': 0.35; 'done': 0.35; 'mapping': 0.35; 'text.': 0.35; 'unicode': 0.35; 'should': 0.36; 'url:org': 0.36; 'others.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'setting': 0.37; 'received:org': 0.37; 'suggestion': 0.37; 'represent': 0.38; 'end': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'some': 0.40; 'address': 0.61; 'more': 0.63; 'our': 0.64; 'skip:\xe2 10': 0.70; '8bit%:43': 0.72; 'upper': 0.76; 'hoping': 0.77; 'low': 0.83; '_o__)': 0.84; 'notably,': 0.84; 'received:125': 0.84; 'ominous': 0.91; 'religion': 0.91; 'works!': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <85zisqratt.fsf@benfinney.id.au>
X-Mailman-Original-References <85oa9cyiqt.fsf@benfinney.id.au> <mailman.90.1460604334.15650.python-list@python.org> <nen5jj$hvi$1@dont-email.me> <85bn5cy6bz.fsf@benfinney.id.au> <8537qoy49y.fsf@benfinney.id.au>
Xref csiph.com comp.lang.python:107275

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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