📅  最后修改于: 2023-12-03 15:18:24.614000             🧑  作者: Mango
IntlChar enumCharNames()函数用于获取Unicode字符的所有名称。Unicode字符可以有多个名称,比如它们的正式名称,别名、注释等。
public static function enumCharNames(int $codepoint, int $group = IntlChar::UNICODE_CHAR_NAME): Generator
IntlChar::UNICODE_CHAR_NAME
:正式名称(默认)。IntlChar::UNICODE_10_CHAR_NAME
:Unicode 1.0的名称。IntlChar::EXTENDED_CHAR_NAME
:扩展名称。IntlChar::CHAR_NAME_ALIAS
:别名。IntlChar::CHAR_NAME_CHOICE
:在显示字符名称时使用的选择格式。IntlChar::CHAR_NAME_ISO_COMMENT
:ISO注释名称。<?php
// 获取Unicode字符 "A" 的正式名称和别名
foreach (IntlChar::enumCharNames(ord("A"), IntlChar::CHAR_NAME_ALIAS) as $name) {
echo $name . "\n";
}
输出:
A
LATIN CAPITAL LETTER A
LATIN LETTER CAPITAL A
LATIN CAPITAL LETTER A, ROUNDED FORM
LATIN CAPITAL LETTER ALPHA
A
ANGSTROM SIGN
ACE OF CLUBS