Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting all Unicode aliases for a codepoint

Tags:

unicode

perl

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?

like image 644
Borodin Avatar asked Feb 23 '26 20:02

Borodin


1 Answers

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.

like image 78
ikegami Avatar answered Feb 26 '26 10:02

ikegami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!