class Normalizer (View source)

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.

Constants

NFKC_CF

FORM_KC_CF

OPTION_DEFAULT

Default normalization options

NONE

No decomposition/composition

FORM_D

Normalization Form D (NFD) - Canonical Decomposition

NFD

FORM_KD

Normalization Form KD (NFKD) - Compatibility Decomposition

NFKD

FORM_C

Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition

NFC

FORM_KC

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

NFKC

Methods

static string|false
normalize(string $string, int $form = Normalizer::FORM_C, $arg3)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Normalizes the input provided and returns the normalized string

static bool
isNormalized(string $string, int $form = Normalizer::FORM_C, $arg3)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Checks if the provided string is already in the specified normalization form.

static string|null
getRawDecomposition(string $string, int $form = 16)

Gets the Decomposition_Mapping property for the given UTF-8 encoded code point

Details

static string|false normalize(string $string, int $form = Normalizer::FORM_C, $arg3)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Normalizes the input provided and returns the normalized string

Parameters

string $string

The input string to normalize

int $form

One of the normalization forms.

$arg3

Return Value

string|false

The normalized string or FALSE if an error occurred.

static bool isNormalized(string $string, int $form = Normalizer::FORM_C, $arg3)

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Checks if the provided string is already in the specified normalization form.

Parameters

string $string

The input string to normalize

int $form

One of the normalization forms.

$arg3

Return Value

bool

TRUE if normalized, FALSE otherwise or if there an error

static string|null getRawDecomposition(string $string, int $form = 16)

Since: 7.3

Gets the Decomposition_Mapping property for the given UTF-8 encoded code point

Gets the Decomposition_Mapping property, as specified in the Unicode Character Database (UCD), for the given UTF-8 encoded code point.

Parameters

string $string

The input string to normalize

int $form

Return Value

string|null

Returns a string containing the Decomposition_Mapping property, if present in the UCD. Returns null if there is no Decomposition_Mapping property for the character.