📅  最后修改于: 2023-12-03 15:33:33.830000             🧑  作者: Mango
IntlChar
是PHP的一个扩展库,提供了一系列的函数可以对Unicode字符进行操作。enumCharTypes()
函数就是其中之一。
该函数用于获取一个Unicode字符所属的类型,返回一个枚举值。该枚举值有21个取值,分别代表21种类型。如下所示:
const TYPE_UNASSIGNED = 0;
const TYPE_GENERAL_OTHERS = 1;
const TYPE_UPPERCASE_LETTER = 2;
const TYPE_LOWERCASE_LETTER = 3;
const TYPE_TITLECASE_LETTER = 4;
const TYPE_MODIFIER_LETTER = 5;
const TYPE_OTHER_LETTER = 6;
const TYPE_NON_SPACING_MARK = 7;
const TYPE_ENCLOSING_MARK = 8;
const TYPE_COMBINING_SPACING_MARK = 9;
const TYPE_DECIMAL_DIGIT_NUMBER = 10;
const TYPE_LETTER_NUMBER = 11;
const TYPE_OTHER_NUMBER = 12;
const TYPE_SPACE_SEPARATOR = 13;
const TYPE_LINE_SEPARATOR = 14;
const TYPE_PARAGRAPH_SEPARATOR = 15;
const TYPE_CONTROL = 16;
const TYPE_FORMAT = 17;
const TYPE_SURROGATE = 18;
const TYPE_PRIVATE_USE = 19;
const TYPE_UNASSIGNED2 = 20;
IntlChar::enumCharTypes ( mixed $codepoint )
返回一个枚举指,代表该字符的类型。
<?php
echo IntlChar::enumCharTypes('d'); // TYPE_LOWERCASE_LETTER
echo IntlChar::enumCharTypes('A'); // TYPE_UPPERCASE_LETTER
echo IntlChar::enumCharTypes('1'); // TYPE_DECIMAL_DIGIT_NUMBER
echo IntlChar::enumCharTypes(' '); // TYPE_SPACE_SEPARATOR
echo IntlChar::enumCharTypes(','); // TYPE_OTHER_PUNCTUATION
?>