获取代码点的所有 Unicode 别名 [英] Getting all Unicode aliases for a codepoint

查看:36
本文介绍了获取代码点的所有 Unicode 别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

charnames 编译指示提供 charnames::viacode 返回给定代码点的最佳"名称

The charnames pragma provides charnames::viacode which returns the "best" name for a given code point

例如

$ perl -Mcharnames=:full -E'say charnames::viacode(ord "A")'
LATIN CAPITAL LETTER A

是否有一种方便的方法可以从 Perl 中发现该名称的所有已知别名?

Is there a convenient way to discover all known aliases for this name from within Perl?

推荐答案

要获取代码点的 Unicode 别名,可以使用以下命令:

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.

例如,这为 U+0020 SPACE 返回 SP.

For example, this returns SP for U+0020 SPACE.

可以在此处找到完整列表.

有关您可以传递给 \N{} 的所有值,请参阅此处.

For all the values you can pass to \N{}, see here.

这篇关于获取代码点的所有 Unicode 别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆