(PHP 7, PHP 8)
IntlChar::enumCharTypes — 列舉所有具有 Unicode 通用類別的程式碼點
有效率地列舉所有程式碼點及其 Unicode 通用類別。這對於構建資料結構、列舉所有已分配的程式碼點等非常有用。
對於每個具有指定通用類別(「字元類型」)的連續程式碼點範圍,將會呼叫 callback
函式。相鄰範圍具有不同的類型。Unicode 標準保證類型的數值為 0..31。
不返回任何值。
範例 #1 列舉程式碼點的樣本範圍
<?php
IntlChar::enumCharTypes(function($start, $end, $type) {
printf("U+%04x 到 U+%04x 屬於類別 %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 ...