Home

Awesome

Run command with CJK-friendly wcwidth(3) to fix ambiguous width chars

What's this?

This is a $LD_PRELOAD-able library and a wrapper script to run a command with CJK-friendly wcwidth(3) implementation for fixing "East Asian Ambiguous Width Characters" problem.

日本語 (In Japanese): 「East Asian Ambiguous Width chars 問題」を 解決するための $LD_PRELOAD 可能な共有ライブラリーとラッパー スクリプトです。「α」などの「East Asian Ambiguous Width chars」の 表示や編集で問題が発生するコマンドをこの実装下で起動すると、 システム標準の wcwidth(3) が置き換えられ、問題を解消できます。

How to build

Required packages: autoconf, automake, libtool, make, cc (gcc or misc)

$ sh autogen.sh
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

Usage

Run a command with $LD_PRELOAD-able library:

$ export LD_PRELOAD=/usr/local/lib/wcwidth-cjk.so
$ exec zsh -l
...

or:

$ eval `/usr/local/bin/wcwidth-cjk --sh-init`
$ exec zsh -l
...

Run a command via wrapper script:

$ /usr/local/bin/wcwidth Ab漢α¥
1 00 00 00 41   A
1 00 00 00 62   b
2 00 00 6F 22   漢
1 00 00 03 B1   α
1 00 00 00 A5   ¥
$ /usr/local/bin/wcwidth-cjk /usr/local/bin/wcwidth Ab漢α¥
1 00 00 00 41   A
1 00 00 00 62   b
2 00 00 6F 22   漢
2 00 00 03 B1   α
1 00 00 00 A5   ¥
$ exec /usr/local/bin/wcwidth-cjk zsh -l
...

References