Ok, I had another look on this one, and it looks to me that we could quite
easily drop the dependency. The code of this library itself is very close of
what I did in the wrapper part, I think.
The first difficulty is to wrap where it's legal, ie after space or after
every CJK char. For that, we could use the same trick than
libtext-wrapi18n-perl:
>>>>>>>>>>>>>>>>>
# Returns 1 for Chinese and Japanese characters. This means that
# these characters allow line wrapping after this character even
# without whitespaces because these languages don't use whitespaces
# between words.
#
# Character must be given in UCS-4 codepoint value.
sub _isCJ {
my $u=shift;
if ($u >= 0x3000 && $u <= 0x312f) {
if ($u == 0x300a || $u == 0x300c || $u == 0x300e ||
$u == 0x3010 || $u == 0x3014 || $u == 0x3016 ||
$u == 0x3018 || $u == 0x301a) {return 0;}
return 1;
} # CJK punctuations, Hiragana, Katakana, Bopomofo
if ($u >= 0x31a0 && $u <= 0x31bf) {return 1;} # Bopomofo
if ($u >= 0x31f0 && $u <= 0x31ff) {return 1;} # Katakana extension
if ($u >= 0x3400 && $u <= 0x9fff) {return 1;} # Han Ideogram
if ($u >= 0xf900 && $u <= 0xfaff) {return 1;} # Han Ideogram
if ($u >= 0x20000 && $u <= 0x2ffff) {return 1;} # Han Ideogram
return 0;
}
<<<<<<<<<<<<<<<<<<<<
Then, the second difficulty is to compute the char width in column right.
Google finds this:
http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
Reimplementing this in perl seems quite easy. But I'm not sure this source
can be trusted, and I feel just too lazy to download the libc source to see
how it's done in there...
Bye, Mt.