(PHP 7, PHP 8)
IntlChar::enumCharTypes — 枚举所有代码点及其 Unicode 通用类别
有效地枚举所有代码点及其 Unicode 通用类别。这对于构建数据结构、枚举所有分配的代码点等很有用。
对于具有给定通用类别(“字符类型”)的每个连续代码点范围,都会调用 callback
函数。相邻范围具有不同的类型。Unicode 标准保证类型的数值为 0..31。
不返回值。
示例 #1 枚举样本代码点范围
<?php
IntlChar::enumCharTypes(function($start, $end, $type) {
printf("U+%04x through U+%04x are in category %d\n", $start, $end, $type);
});
?>
上面的示例将输出
U+0000 through U+0020 are in category 15 U+0020 through U+0021 are in category 12 U+0021 through U+0024 are in category 23 U+0024 through U+0025 are in category 25 U+0025 through U+0028 are in category 23 U+0028 through U+0029 are in category 20 U+0029 through U+002a are in category 21 U+002a through U+002b are in category 23 U+002b through U+002c are in category 24 U+002c through U+002d are in category 23 U+002d through U+002e are in category 19 U+002e through U+0030 are in category 23 U+0030 through U+003a are in category 9 ...