Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of known Unicode characters names

Tags:

unicode

perl

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.

like image 531
Alexandr Evstigneev Avatar asked Jan 24 '23 22:01

Alexandr Evstigneev


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 "";
}
like image 108
Shawn Avatar answered Jan 29 '23 08:01

Shawn