I18N_UnicodeNormalizer
[ class tree: I18N_UnicodeNormalizer ] [ index: I18N_UnicodeNormalizer ] [ all elements ]

Class: I18N_UnicodeNormalizer

Source Location: /I18N_UnicodeNormalizer-1.0.0/UnicodeNormalizer.php

Class Overview


Unicode Normalizer


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2007 Michel Corne

Methods


Inherited Variables

Inherited Methods


Class Details

[line 87]
Unicode Normalizer

Performs the 4 normalizations: NFD, NFC, NFKD, NFKC.

 Example 1: NFC-normalization of UTF-8 string 'foo'
 $normalized = I18N_UnicodeNormalizer::toNFC('foo');
 or
 $normalizer = new I18N_UnicodeNormalizer();
 $normalized = $normalizer->normalize('foo', 'NFC')

 Example 2: NFC-normalization of ISO-8859-1 string 'foo'
 $normalized = I18N_UnicodeNormalizer::toNFC('foo', 'ISO-8859-1');
 or
 $normalizer = new I18N_UnicodeNormalizer();
 $normalized = $normalizer->normalize('foo', 'NFC', 'ISO-8859-1')



[ Top ]


Method Detail

__construct (Constructor)   [line 207]

void __construct( [string $dir = ''])

The class constructor

Sets the paths to the data/compiled files.

  • Access: public

Parameters:

string   $dir     the data/compiled files base directory, this is only to be used if it cannot be determined automaticly, or by the package maintainers for testing purposes

[ Top ]

getCharInfo   [line 234]

array getCharInfo( mixed $chars, string $type)

Gets some information for a set of characters

Finds if the characters pass the quick check. Finds their combining classes, their compositions and their decomposition mappings. Mainly used for debugging/testing purposes.

  • Return: the information, up to 4 sub-arrays, with the characters as keys and the corresponding quick check value, or combining class, or compositions, or decomposition mappingsm converted to the UCN format.
  • Access: public

Parameters:

mixed   $chars     the UTF-8 characters to get the information for, either as a string or an array of characters
string   $type     the type of normalization: 'NFC', 'NFD', 'NFKC' or 'NFKD'

[ Top ]

getDataDir   [line 312]

string getDataDir( )

Determines the data/compiled files directory

In case of a raw install coming for example from the SVN repository, the data/compiled files directory is expected to be in the same directory as this file. In case of a Pear install, the data/compiled files directory is computed by PEAR_Config.

  • Return: the data/compiled files base directory
  • Access: public

[ Top ]

getFileNames   [line 340]

array getFileNames( [string $dir = ''])

Gets the name list of the compiled files
  • Return: the name list of compiled files
  • Access: public

Parameters:

string   $dir     the data/compiled files base directory,

[ Top ]

isStarter   [line 358]

boolean isStarter( string $char, string $type)

Checks if a character is a starter

A starter is a character that passes the quick check and with a combining class equal to 0.

  • Return: true if a starter, false otherwise
  • Access: public

Parameters:

string   $char     the character
string   $type     the type of normalization: 'NFC', 'NFD', 'NFKC' or 'NFKD'

[ Top ]

isValidType   [line 382]

array isValidType( string $type)

Checks if the normalization type is valid: NFC, NFD, NFKC or NKFD
  • Return: true if valid, false otherwise
  • Access: public

Parameters:

string   $type     the normalization type, e.g. 'NFC'

[ Top ]

normalize   [line 398]

mixed normalize( string $string, [string $type = ''], [string $encoding = ''])

Normalizes a string
  • Return: the normalized string
  • Access: public

Parameters:

string   $string     the string to normalize
string   $type     the type of normalization: 'NFC', 'NFD', 'NFKC' or 'NFKD', 'NFC' is the default
string   $encoding     the string encoding, must be compliant with mb_list_encodings(), e.g. 'UFT-16', 'UTF-8' is the defaut

[ Top ]

toNFC   [line 708]

mixed toNFC( string $string, [string $encoding = null])

NFC-normalizes a string
  • Return: the normalized string
  • Access: public

Parameters:

string   $string     the string to normalize
string   $encoding     the string encoding, must be compliant with mb_list_encodings(), e.g. 'UFT-16', 'UTF-8' is the defaut

[ Top ]

toNFD   [line 725]

mixed toNFD( string $string, [string $encoding = null])

NFD-normalizes a string
  • Return: the normalized string
  • Access: public

Parameters:

string   $string     the string to normalize
string   $encoding     the string encoding, must be compliant with mb_list_encodings(), e.g. 'UFT-16', 'UTF-8' is the defaut

[ Top ]

toNFKC   [line 742]

mixed toNFKC( string $string, [string $encoding = null])

NFKC-normalizes a string
  • Return: the normalized string
  • Access: public

Parameters:

string   $string     the string to normalize
string   $encoding     the string encoding, must be compliant with mb_list_encodings(), e.g. 'UFT-16', 'UTF-8' is the defaut

[ Top ]

toNFKD   [line 759]

mixed toNFKD( string $string, [string $encoding = null])

NFKD-normalizes a string
  • Return: the normalized string
  • Access: public

Parameters:

string   $string     the string to normalize
string   $encoding     the string encoding, must be compliant with mb_list_encodings(), e.g. 'UFT-16', 'UTF-8' is the defaut

[ Top ]


Documentation generated on Sat, 04 Aug 2007 11:00:13 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.