keithw/mosh — pull request #375 by knu (2013-01-16 20:49:57+00:00)
Title: Add support for East Asian Width

Mosh currently uses wcwidth(3) for computing the width of each character, but the somewhat outdated standard function does not take East Asian Width (http://www.unicode.org/reports/tr11/) into account.

Characters marked as having an "ambiguous" width should be displayed as wide character under East Asian (CJK) locales while they should be narrow under non-CJK locales.

Most major terminal emulators, terminal multiplexers and terminal-based text editors support this option, so I believe mosh should too. Here's an incomplete list of those that support it:

- xterm
- GNOME terminal
- Konsole + unofficial patch
- PuTTY + unofficial patch
- iTerm2
- GNU screen (4.01.00+)
- tmux + unofficial patch
- GNU Emacs
- Vim
…

My patch is a quick hack that simply does the job with a least effort and hopefully with a least overhead.
To do it a cleaner way, you may want to consider using ICU (http://site.icu-project.org) which offers a native C++ API to the Unicode database, though I'm not sure how it impacts on performance.