The Normalizer class

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

简介

Normalization is a process that involves transforming characters and sequences of characters into a formally-defined underlying representation. This process is most important when text needs to be compared for sorting and searching, but it is also used when storing text to ensure that the text is stored in a consistent representation.

The Unicode Consortium has defined a number of normalization forms reflecting the various needs of applications:

  • Normalization Form D (NFD) - Canonical Decomposition
  • Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition
  • Normalization Form KD (NFKD) - Compatibility Decomposition
  • Normalization Form KC (NFKC) - Compatibility Decomposition followed by Canonical Composition
The different forms are defined in terms of a set of transformations on the text, transformations that are expressed by both an algorithm and a set of data files.

类摘要

class Normalizer {
/* 常量 */
public const int FORM_D;
public const int NFD;
public const int FORM_KD;
public const int NFKD;
public const int FORM_C;
public const int NFC;
public const int FORM_KC;
public const int NFKC;
public const int FORM_KC_CF;
public const int NFKC_CF;
/* 方法 */
public static getRawDecomposition(string $string, int $form = Normalizer::FORM_C): ?string
public static isNormalized(string $string, int $form = Normalizer::FORM_C): bool
public static normalize(string $string, int $form = Normalizer::FORM_C): string|false
}

预定义常量

The following constants define the normalization form used by the normalizer:

Normalizer::FORM_C
Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition
Normalizer::FORM_D
Normalization Form D (NFD) - Canonical Decomposition
Normalizer::NFD

Normalizer::FORM_KC
Normalization Form KC (NFKC) - Compatibility Decomposition, followed by Canonical Composition
Normalizer::NFKC

Normalizer::FORM_KC_CF

Normalizer::FORM_KD
Normalization Form KD (NFKD) - Compatibility Decomposition
Normalizer::NFKD

Normalizer::NFC

Normalizer::NFKC_CF

更新日志

版本 说明
8.0.0 Normalizer::NONE has been removed.

目录

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top