Custom Character Names
You can create custom character names to allow for more convenient typing or to give names to codepoints Unicode hasn’t assigned a name to. Aliases are added either using anonymous hashes:
use charnames ":alias" => {
e_ACUTE => "LATIN SMALL LETTER E WITH ACUTE",
"APPLE LOGO" => 0xF8FF, # private–use codepoint
};
my $str = "\N{APPLE LOGO}";or using a file containing a list of key/value pairs:
use charnames ":alias" => "pro"; # look in unicore/pro_alias.pl
The specified file should be under a unicore/ subdirectory somewhere in the
@INC path, and it should be named
using a trailing _alias.pl at the
end. So, for example, the file looked for above will be unicore/pro_alias.pl. This file should return
a list in plain Perl:
(
A_grave => "LATIN CAPITAL LETTER A WITH GRAVE",
A_circ => "LATIN CAPITAL LETTER A WITH CIRCUMFLEX",
A_diaer => "LATIN CAPITAL LETTER A WITH DIAERESIS",
A_dier => "LATIN CAPITAL LETTER A WITH DIAERESIS",
A_uml => "LATIN CAPITAL LETTER A WITH DIAERESIS",
A_tilde => "LATIN CAPITAL LETTER A WITH TILDE",
A_macron => "LATIN CAPITAL LETTER A WITH MACRON",
);Both these methods insert :full
automatically as the first argument if no other argument is given; you
can also give the :full
explicitly:
use charnames ":full", ":alias" => "pro";
Even private-use characters can gain names. For example, after:
use charnames ":full", ":alias" => { "TENGWAR LETTER TINCO" => 0xE000, "TENGWAR LETTER PARMA" => 0xE001, "TENGWAR LETTER CALMA" => 0xE002, "TENGWAR LETTER QUESSE" ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access