Unicode::EastAsianWidth - East Asian Width properties
use Unicode::EastAsianWidth; $_ = chr(0x2010); # HYPHEN, an ambiguous-width character /\p{InEastAsianAmbiguous}/; # True /\p{InFullwidth}/; # False
To mark ambiguous-width characters as InFullwidth:
BEGIN { $Unicode::EastAsianWidth::EastAsian = 1; } use Unicode::EastAsianWidth; $_ = chr(0x2010); # HYPHEN, an ambiguous-width character /\p{InFullwidth}/; # True
This module provide user-defined Unicode properties that deal with width status of East Asian characters, as specified in http://www.unicode.org/unicode/reports/tr11/.
It exports the following functions to the caller's scope, to be used by Perl's Unicode matching system: InEastAsianFullwidth, InEastAsianHalfwidth, InEastAsianAmbiguous, InEastAsianNarrow InEastAsianWide, InEastAsianNeutral.
InEastAsianFullwidth
InEastAsianHalfwidth
InEastAsianAmbiguous
InEastAsianNarrow
InEastAsianWide
InEastAsianNeutral
In accord to TR11 cited above, two additional context-sensitive properties are exported: InFullwidth (union of Fullwidth and Wide) and InHalfwidth (union of Halfwidth, Narrow and Neutral).
InFullwidth
Fullwidth
Wide
InHalfwidth
Halfwidth
Narrow
Neutral
Ambiguous characters are treated by default as part of InHalfwidth, but you can modify this behaviour by assigning a true value to $Unicode::EastAsianWidth::EastAsian at compile time within a BEGIN block before loading this module:
$Unicode::EastAsianWidth::EastAsian
BEGIN
BEGIN { $Unicode::EastAsianWidth::EastAsian = 1; } use Unicode::EastAsianWidth;
Setting $Unicode::EastAsianWidth::EastAsian at run-time used to work on Perl versions between 5.8 and 5.14 due to an implementation detail, but it will no longer work on Perl 5.16 and later versions, and hence is not recommended.
perlunicode, http://www.unicode.org/unicode/reports/tr11/
唐鳳 <cpan@audreyt.org>
This work is under the CC0 1.0 Universal license.
To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Unicode-EastAsianWidth.
This work is published from Taiwan.
http://creativecommons.org/publicdomain/zero/1.0
To install Unicode::EastAsianWidth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Unicode::EastAsianWidth
CPAN shell
perl -MCPAN -e shell install Unicode::EastAsianWidth
For more information on module installation, please visit the detailed CPAN module installation guide.