Mac Terminal has garbled characters

Sometimes working in a character cell terminal, you will end up with garbled characters. This is actually the result of some program sending a Control-N (Shift In) character, which causes a graphic character set to be selected. Here are the some other ways and the details. It all boils down to selecting a different character set on the VT100 series terminal as detailed starting on page 307 (A-15) of this BIG PDF.

Here is a way that often works.

    1. Press Enter (to get a new mangled shell prompt).

    2. Type tr A-Z '\017' and Enter

    3. Type some uppercase letters (like BEEF) and Enter

    4. Press Control-D or Control-C and Enter

    5. Enjoy a restored terminal session.

Here is a picture with the magic command highlighted in the normal session on the right, and the formerly mangled session on the left.

Purists will note that I should have typed kdkdkdk and Enter before the AAA to prove that the session was messed up and

corrected by translating the AAA into three Control-O characters. Not that we needed three, but hey it doesn't hurt :-)

Other ways to get a mangled session are mentioned on 309 (A-17) as ESC ( 0, ESC ( 1 and ESC ( 2 . A remote possibility is the VT52 mode emulation sequence ESC F , see page 308 (A-16). These modes are undone with ESC ( B or if you are British ESC ( A .

Okay: Here's the US and British # character. I highlighted the British one:

The "Type a control-O" trick doesn't seem to work, nor does echo Control-V Control-O. This seems to be because the Control-O is the terminal discipline's discard (also known as flush) character. See man stty for an obscure definition.

Chris Lent 20110423T183541

And here shows the definition