Normalizer::getRawDecomposition

normalizer_get_raw_decomposition

(PHP 7 >= 7.3, PHP 8)

Normalizer::getRawDecomposition -- normalizer_get_raw_decomposition获取给定 UTF-8 编码代码点的 Decomposition_Mapping 属性

描述

面向对象风格

public static Normalizer::getRawDecomposition(string $string, int $form = Normalizer::FORM_C): ?string

过程式风格

normalizer_get_raw_decomposition(string $string, int $form = Normalizer::FORM_C): ?string

获取给定 UTF-8 编码代码点的 Decomposition_Mapping 属性,如 Unicode 字符数据库 (UCD) 中所指定。

参数

string

输入字符串,应该是单个 UTF-8 编码的代码点。

返回值

如果 UCD 中存在 Decomposition_Mapping 属性,则返回包含 Decomposition_Mapping 属性的 string

如果字符没有 Decomposition_Mapping 属性,则返回 null

示例

示例 #1 Normalizer::getRawDecomposition() 示例

<?php

$result
= "";
$strings = [
"a",
"\u{FFDA}",
"\u{FDFA}",
"",
"aa",
"\xF5",
];

foreach (
$strings as $string) {
$decomposition = Normalizer::getRawDecomposition($string);
// $decomposition = normalizer_get_raw_decomposition($string); 过程式方法

$error_code = intl_get_error_code();
$error_message = intl_get_error_message();

$string_hex = bin2hex($string);
$result .= "---------------------\n";

if (
$decomposition === null) {
$result .= "'$string_hex' has no decomposition mapping\n" ;
} else {
$result .= "'$string_hex' has the decomposition mapping '" . bin2hex($decomposition) . "'\n" ;
}

$result .= "error info: '$error_message' ($error_code)\n";
}

echo
$result;
?>

上面的示例将输出

---------------------
'61' has no decomposition mapping
error info: 'U_ZERO_ERROR' (0)
---------------------
'efbf9a' has the decomposition mapping 'e385a1'
error info: 'U_ZERO_ERROR' (0)
---------------------
'efb7ba' has the decomposition mapping 'd8b5d984d98920d8a7d984d984d98720d8b9d984d98ad98720d988d8b3d984d985'
error info: 'U_ZERO_ERROR' (0)
---------------------
'' has no decomposition mapping
error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
---------------------
'6161' has no decomposition mapping
error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
---------------------
'f5' has no decomposition mapping
error info: 'Code point out of range: U_ILLEGAL_ARGUMENT_ERROR' (1)

参见

添加注释

用户贡献的注释

此页面没有用户贡献的注释。
To Top