The charnames pragma provides charnames::viacode which returns the "best" name for a given code point
For instance
$ perl -Mcharnames=:full -E'say charnames::viacode(ord "A")'
LATIN CAPITAL LETTER A
Is there a convenient way to discover all known aliases for this name from within Perl?
To get the Unicode aliases of a code point, you can use the following:
use Unicode::UCD qw( charprop );
my @aliases =
map { s/:.*//sr }
split /,/,
charprop($ucp, "Name_Alias"); # $ucp is the Unicode code point as a number.
For example, this returns SP for U+0020 SPACE.
The complete list can be found here.
For all the values you can pass to \N{}, see here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With