Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\StringNormalizer Class Reference

StringNormalizer provides several methods for normalizing strings. More...

Public Member Functions

 trimBadChars ( $string)
 Remove incomplete UTF-8 sequences from the beginning and end of the string. More...
 
 trimWhitespace ( $inputString)
 Trim initial and trailing whitespace and control chars, and compress some internal control chars. More...
 
 cleanupToNFC ( $inputString)
 Normalize string into NFC by using the cleanup method from UtfNormal. More...
 
 trimToNFC ( $inputString)
 Do a cleanupToNFC after the string is trimmed. More...
 

Protected Member Functions

 removeBadCharLast ( $string)
 Remove bytes that represent an incomplete Unicode character at the end of string (e.g. More...
 
 removeBadCharFirst ( $string)
 Remove bytes that represent an incomplete Unicode character at the start of string (e.g. More...
 

Detailed Description

StringNormalizer provides several methods for normalizing strings.

Author
Daniel Kinzler
John Erling Blad < jebla.nosp@m.d@gm.nosp@m.ail.c.nosp@m.om >

Member Function Documentation

◆ cleanupToNFC()

Wikibase\Lib\StringNormalizer::cleanupToNFC (   $inputString)

Normalize string into NFC by using the cleanup method from UtfNormal.

Parameters
string$inputStringThe actual string to process.
Returns
string

◆ removeBadCharFirst()

Wikibase\Lib\StringNormalizer::removeBadCharFirst (   $string)
protected

Remove bytes that represent an incomplete Unicode character at the start of string (e.g.

bytes of the char are missing)

Todo:
this was stolen from the Language class. Make that code reusable.
Parameters
string$string
Returns
string

◆ removeBadCharLast()

Wikibase\Lib\StringNormalizer::removeBadCharLast (   $string)
protected

Remove bytes that represent an incomplete Unicode character at the end of string (e.g.

bytes of the char are missing)

Todo:
this was stolen from the Language class. Make that code reusable.
Parameters
string$string
Returns
string

◆ trimBadChars()

Wikibase\Lib\StringNormalizer::trimBadChars (   $string)

Remove incomplete UTF-8 sequences from the beginning and end of the string.

Parameters
string$string
Returns
string

◆ trimToNFC()

Wikibase\Lib\StringNormalizer::trimToNFC (   $inputString)

Do a cleanupToNFC after the string is trimmed.

Parameters
string$inputString
Returns
string on NFC form

◆ trimWhitespace()

Wikibase\Lib\StringNormalizer::trimWhitespace (   $inputString)

Trim initial and trailing whitespace and control chars, and compress some internal control chars.

Parameters
string$inputStringThe actual string to process.
Returns
string where whitespace possibly are removed.

The documentation for this class was generated from the following file: