Unicode...ianWidth(3)

πŸ“¦
version 12.0 Β· 5 versions
, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay bestie, welcome to the Unicode::EastAsianWidth manual page β€” the whole vibe is East Asian Width properties. that's it, that's the name. πŸ’…

✨ SYNOPSIS ✨

first up, you load it like this:

use Unicode::EastAsianWidth;

$_ = chr(0x2010); # HYPHEN, an ambiguous-width character

/\p{InEastAsianAmbiguous}/; # True
/\p{InFullwidth}/;          # False

so chr(0x2010) is HYPHEN, and it's an ambiguous-width character, and matching /\p{InEastAsianAmbiguous}/; gives # True while /\p{InFullwidth}/; gives # False. slay.

want to mark ambiguous-width characters as InFullwidth? do the BEGIN block before the use, like:

BEGIN { $Unicode::EastAsianWidth::EastAsian = 1; }
use Unicode::EastAsianWidth;

$_ = chr(0x2010); # HYPHEN, an ambiguous-width character
/\p{InFullwidth}/;          # True

same HYPHEN, but now /\p{InFullwidth}/; is # True. periodt. ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

this module gives you user-defined Unicode properties that deal with the width status of East Asian characters, exactly as specified in <http://www.unicode.org/unicode/reports/tr11/>. iconic.

it exports the following functions into the caller's scope, so Perl's Unicode matching system can use them:

  • InEastAsianFullwidth
  • InEastAsianHalfwidth
  • InEastAsianAmbiguous
  • InEastAsianNarrow
  • InEastAsianWide
  • InEastAsianNeutral

in accord with TR11 (cited above), there are also two extra context-sensitive properties exported:

  • InFullwidth β€” the union of Fullwidth and Wide
  • InHalfwidth β€” the union of Halfwidth, Narrow and Neutral

by default, ambiguous characters are treated as part of InHalfwidth. but bestie, you can modify that behaviour by assigning a true value to $Unicode::EastAsianWidth::EastAsian at compile time inside a BEGIN block, before you load this module:

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 because of an implementation detail, but it will no longer work on Perl 5.16 and later versions, so it is not recommended. no cap, don't do the run-time thing. 😭

🌈 SEE ALSO 🌈

go check out perlunicode and the TR11 report at <http://www.unicode.org/unicode/reports/tr11/>. iykyk. πŸ¦‹

πŸ‘‘ AUTHORS πŸ‘‘

the author is Audrey Tang <cpan@audreyt.org>. bow down. πŸ‘‘

πŸŽ€ LICENSE πŸŽ€

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. that's huge. 🫢

This work is published from Taiwan. 🌸

the license link is <http://creativecommons.org/publicdomain/zero/1.0>. go read it, bestie. πŸŽ€


that's the whole page, bestie β€” source/version: perl v5.42.0, dated 2019-09-27, and it's the Unicode::EastAsianWidth manual. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from