IntlChar::enumCharTypes()函數是PHP中的內置函數,用於提供所有代碼點及其Unicode常規類別的目錄。所有編目對所有代碼點都非常有效。對於枚舉所有分配的代碼點和構建數據結構等,這將非常有用。對於具有給定常規類別和字符類型的連續範圍內的每個代碼點,將調用回調函數。相鄰範圍可以具有不同的類型。 Unicode標準保證類型的數字值為0到31。
用法:
void IntlChar::enumCharTypes( $callback )
參數:該函數接受單個參數$callback。對於具有相同一般類別的每個相鄰代碼點範圍,將調用該函數。回調函數包含以下三個參數:
- 整數$start:這是起始代碼點。
- 整數$end:這是結束代碼點。
- 整數$name:類別類型(IntlChar::CHAR_CATEGORY_ *常量之一)
返回值:該函數不返回任何值。
以下示例程序旨在說明PHP中的IntlChar::enumCharTypes()函數:
程序:
<?php
// PHP program to uses IntlChar::enumCharTypes()
// function
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 ...
參考: https://www.php.net/manual/en/intlchar.enumchartypes.php
相關用法
- PHP IntlChar::chr()用法及代碼示例
- PHP IntlChar::ord()用法及代碼示例
- PHP IntlChar::isJavaIDStart()用法及代碼示例
- PHP IntlChar::isIDPart()用法及代碼示例
- PHP IntlChar isdefined()用法及代碼示例
- PHP IntlChar::isISOControl()用法及代碼示例
- PHP IntlChar::isIDStart()用法及代碼示例
- PHP IntlChar::totitle()用法及代碼示例
- PHP IntlChar::isJavaIDPart()用法及代碼示例
- PHP IntlChar foldCase()用法及代碼示例
- PHP IntlChar::isUUppercase()用法及代碼示例
- PHP IntlChar::isIDIgnorable()用法及代碼示例
- PHP IntlChar::charMirror()用法及代碼示例
- PHP IntlChar::charName()用法及代碼示例
- PHP IntlChar charType()用法及代碼示例
注:本文由純淨天空篩選整理自SohomPramanick大神的英文原創作品 PHP | IntlChar enumCharTypes() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。