Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
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.
 
 trimWhitespace ( $inputString)
 Trim initial and trailing whitespace and control chars, and compress some internal control chars.
 
 cleanupToNFC ( $inputString)
 Normalize string into NFC by using the cleanup method from UtfNormal.
 
 trimToNFC ( $inputString)
 Do a cleanupToNFC after the string is trimmed.
 

Protected Member Functions

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

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: