How to get list of known Unicode characters names

Viewed 91

How can I get list of all known names, that can be used in "\N{...}" from perl? Could not figure out to do with Unicode::UCD or other core module.

1 Answers

Unicode::UCD and a loop:

#!/usr/bin/env perl
use strict;
use warnings;
use Unicode::UCD qw/charinfo/;
use feature qw/say/;

say "Character names defined by Unicode ", Unicode::UCD::UnicodeVersion();
for (my $cp = 0; $cp <= 0x10FFFF; $cp += 1) {
    my $info = charinfo($cp);
    say $info->{"name"} if defined $info && $info->{"name"} ne "";
}
Related