Setting up environment to play Chinese MUD on MacOS (with Tintin++)
Update: See bottom for an update
Old Chinese MUDs uses BG* charsets, e.g., GBK, GB2312. Both Terminal app and iTerm2 can be configured and used to play. To set up the terminal:
Hint: Create a dedicated profile for MUD playing, call it "CN MUD"
To properly display GBK characters
- Change terminal app character encoding to BGK (in "advanced")
- Check the box "Unicode East Asian Ambiguous characters are wide" (in "advanced"). With this, the ASCII arts in the game (e.g. maps) will have misalignment.
- After that, the font can be left unchanged, as the English, mono font
To input GBK characters in shell
1 | # zsh autocompletion helps prompting the values |
To input GBK characters in Tintin++
When tt++ is launched, type in:
1 | #config CHARSET GBK |
This config is only documented here. It also didn't mention GBK
as a
valid value, but it seems so.
Without this step, typing GBK characters would freeze tt++ application and you'll have to kill it from another tty.
Update: Tue Sep 22 23:42:37 PDT 2020
I found tmux doesn't work with above solution. Because tmux doesn't support non-UTF8 locales:
LC_CTYPE The character encoding locale(1). It is used for two separate
purposes. For output to the terminal, UTF-8 is used if the -u
option is given or if LC_CTYPE contains "UTF-8" or "UTF8".
Otherwise, only ASCII characters are written and non-ASCII
characters are replaced with underscores (`_')...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Luckily I found another more elegant way to solve the problem without changing
terminal locale - using luit
luit
can convert a single non-UTF8 program's input and output between UTF8 and
a specified locale. Since tmux doesn't non-UTF8, so it is NOT useful to attempt
luit -encoding GBK tmux
. However, within a tmux pane, it is useful to do:
1 | luit -encoding GBK tt++ |
In another tmux pane for displaying logging:
1 | luit -encoding tail -f chat.log |
TMUX setup
No matter luit or not, the terminal app needs to display east asian wide characters wide. However, once it's enabled, tmux's pane splitter would look strange. The vertical splitter would be invisible most of the time.
To fix this, tmux 3.2 introduced a setting pane-boarder-lines
that allows use
only ASCII characters for the splitters.
I was able to build tmux 3.2rc from source tarball easily on MacOS:
1 | ./configure && make |
Once that, start the tmux and set:
1 | set pane-boarder-lines simple |
Would solve the problem.
Thu Aug 18 23:29:08 PDT 2022
I found easiest way is:
- use native terminal without using tmux
- set terminal encoding to gbk
- enable "ambiguous characters are double-width"
- in tt++, use
#config CHARSET GBK
to type chinese characters- tt++ also supports GBK to UTF conversion (
#config charset GBK1TOUTF8
). See tt++ faq
- tt++ also supports GBK to UTF conversion (