星期五, 12月 26, 2014

Escaping from alternative charset (weird characters in tmux)

When I'm playing mud, sometimes my terminal run into a queer mode that leaves the characters all messed up:
After some research I found that it's because the terminal went into the 'Alternative charset' mode, that translate some characters to symbols (See the last section of man 5 termcap). As for the reason why it went into this mode, it's because that I accidentally echoed '^N' into the terminal. To escape, you can simply echo '^O' to restore the state. most common way:

$ cat
^O
^D
or you can use echo, if your shell supports entering special characters
$ echo ^V^O
If you want to reproduce this, just change the ^O above to ^N then you'll find yourself in the AC mode again.

Some in-depth explanation and other more complicated cases are described here:
http://www.in-ulm.de/~mascheck/various/alternate_charset/