首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Normalizer (class)

Introduction

(PHP 5 >= 5.3.0, PHP 7, 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 synopsis

Normalizer {

/* Methods */

代码语言:javascript
复制
public static bool isNormalized ( string $input [, int $form = Normalizer::FORM_C ] )
代码语言:javascript
复制
public static string normalize ( string $input [, int $form = Normalizer::FORM_C ] )

}

Predefined Constants

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

Normalizer::FORM_C (integer) Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition Normalizer::FORM_D (integer) Normalization Form D (NFD) - Canonical DecompositionNormalizer::FORM_KC (integer) Normalization Form KC (NFKC) - Compatibility Decomposition, followed by Canonical Composition Normalizer::FORM_KD (integer) Normalization Form KD (NFKD) - Compatibility Decomposition Normalizer::NONE (integer) No decomposition/compositionNormalizer::OPTION_DEFAULT (integer) Default normalization options

See Also

Table of Contents

  • Normalizer::isNormalized — Checks if the provided string is already in the specified normalization form.
  • Normalizer::normalize — Normalizes the input provided and returns the normalized string

← Locale::setDefault

Normalizer::isNormalized →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com