Entering Japanese Multibyte Charaters on the command line
I become a happier coder the day I realised I could (relatively) painlessly use and IME on the commandline aswell :).
There’s a number of hoops one has to jump through, if anyone is not setup then export your input to be borked:
- server/environment config
- bash (shell) config
- terminal emulation config (e.g. xterm, Terminal.app)
- application config (vim, emacs, mysql client etc)
Each has it’s own delicious variety of syntax and variables you need to set, so allowing for all the more fun and multiple ways of it not working.
Anyway I originally published the a how to on my blog for vim OSX and bash:
http://www.mrkirkland.com/vim-japanese-os-x/
Here’s the juicy:
- vim
-
:set enc=utf-8
:set fenc=utf-8
:set fencs=iso-2022-jp,euc-jp,cp932
- Edit ~/.profile and add:
export LC_CTYPE=en_US.UTF-8
Edit ~/.inputrc and add:
set input-meta on
set output-meta on
set convert-meta off
set meta-flag on
set output-meta on
-
- File -> Show Info (ファイル>情報を見る)
- Emulation (エミュレーション)
- uncheck Escape non-Ascii characters (非Ascii文字をエスケープする)
- Display (ディスプレイ)
- Check “Wide glyphs count as 2 columns” (ワイドグリフは2桁とカウントする) and “Wide glyphs for Japanes/Chinese/etc.”(日本語や中国語などにワイドグリフを使用する)
bash
Mac OS X Terminal.app
Anyone else got any gems to add to this list?