Ben Finney <ben+pyt...@benfinney.id.au> writes: > Ben Finney <ben+pyt...@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 -- https://mail.python.org/mailman/listinfo/python-list