in reply to The “real length" of UTF8 strings
sub visual_length { my $s = shift; my $l = 0; while ($s =~ m/(.)/g){ my $c = $1; if ($c =~ m/\p{M}){ # do nothing } elsif ($c =~ m/\p{Han}) { $l += 2; } else { $l++; } } return $l; }
That could use much more tweaking, but maybe it's a start for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: The “real length" of UTF8 strings
by Anonymous Monk on Sep 24, 2008 at 04:32 UTC | |
by moritz (Cardinal) on Sep 24, 2008 at 07:57 UTC |