是否有charnames::viacode()
的版本会返回代码点的短名称,即use charnames ':short'
生效时可以使用的名称?
use charnames ':short';
my $x = ord("\N{Cyrillic::es}");
say "long name: ", charnames::viacode($x); # prints "CYRILLIC SMALL LETTER ES"
say "short name: ", ???($x); # want: Cyrillic:es
答案 0 :(得分:1)
SCRIPTNAME:CHARNAME
搜索
所以你可以使用
sub short_name {
my ($long_name) = @_;
return "$1:\U$2" if $long_name =~ /^(\S+) CAPITAL LETTER (\S+)\z/;
return "$1:\L$2" if $long_name =~ /^(\S+) SMALL LETTER (\S+)\z/;
return "$1:$2" if $long_name =~ /^(\S+) LETTER (\S+)\z/;
return $long_name;
}