\Symfony\Component\StringUnicodeString

Represents a string of Unicode grapheme clusters encoded as UTF-8.

A letter followed by combining characters (accents typically) form what Unicode defines as a grapheme cluster: a character as humans mean it in written texts. This class knows about the concept and won't split a letter apart from its combining accents. It also ensures all string comparisons happen on their canonically-composed representation, ignoring e.g. the order in which accents are listed when a letter has many of them.

Summary

Methods
Properties
Constants
fromCodePoints()
ascii()
camel()
codePointsAt()
folded()
join()
lower()
match()
normalize()
padBoth()
padEnd()
padStart()
replaceMatches()
reverse()
snake()
title()
trim()
trimEnd()
trimStart()
upper()
width()
__construct()
unwrap()
wrap()
after()
afterLast()
append()
before()
beforeLast()
bytesAt()
chunk()
collapseWhitespace()
containsAny()
endsWith()
ensureEnd()
ensureStart()
equalsTo()
ignoreCase()
indexOf()
indexOfLast()
isEmpty()
jsonSerialize()
length()
prepend()
repeat()
replace()
slice()
splice()
split()
startsWith()
toByteString()
toCodePointString()
toString()
toUnicodeString()
truncate()
wordwrap()
__sleep()
__clone()
__toString()
__wakeup()
No public properties found
NFC
NFD
NFKC
NFKD
ASCII
FOLD_FROM
FOLD_TO
UPPER_FROM
UPPER_TO
TRANSLIT_FROM
TRANSLIT_TO
PREG_PATTERN_ORDER
PREG_SET_ORDER
PREG_OFFSET_CAPTURE
PREG_UNMATCHED_AS_NULL
PREG_SPLIT
PREG_SPLIT_NO_EMPTY
PREG_SPLIT_DELIM_CAPTURE
PREG_SPLIT_OFFSET_CAPTURE
No protected methods found
$string
$ignoreCase
N/A
pad()
wcswidth()
$transliterators
N/A

Constants

NFC

NFC = \Normalizer::NFC

NFD

NFD = \Normalizer::NFD

NFKC

NFKC = \Normalizer::NFKC

NFKD

NFKD = \Normalizer::NFKD

ASCII

ASCII = " eiasntrolud][cmp'\ng|hv.fb,:=-q10C2*yx)(L9AS/P\"EjMIk3>5T<D4}B{8FwR67UGN;JzV#HOW_&!K?XQ%Y\\\tZ+~^\$@`\x00\x01\x02\x03\x04\x05\x06\x07\x08\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"

FOLD_FROM

FOLD_FROM = ['İ', 'µ', 'ſ', "ͅ", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "ι", 'ß', 'İ', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ']

FOLD_TO

FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'i̇', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ']

UPPER_FROM

UPPER_FROM = ['ß', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', 'ΐ', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ']

UPPER_TO

UPPER_TO = ['SS', 'FF', 'FI', 'FL', 'FFI', 'FFL', 'ST', 'ST', 'ԵՒ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', 'ɬ', 'ɭ', 'ɱ', 'ɲ', 'ɳ', 'ɴ', 'ɶ', 'ɼ', 'ɽ', 'ɾ', 'ʀ', 'ʂ', 'ʈ', 'ʉ', 'ʋ', 'ʏ', 'ʐ', 'ʑ', 'ʙ', 'ʛ', 'ʜ', 'ʝ', 'ʟ', 'ʠ', 'ʣ', 'ʥ', 'ʦ', 'ʪ', 'ʫ', 'ᴀ', 'ᴁ', 'ᴃ', 'ᴄ', 'ᴅ', 'ᴆ', 'ᴇ', 'ᴊ', 'ᴋ', 'ᴌ', 'ᴍ', 'ᴏ', 'ᴘ', 'ᴛ', 'ᴜ', 'ᴠ', 'ᴡ', 'ᴢ', 'ᵫ', 'ᵬ', 'ᵭ', 'ᵮ', 'ᵯ', 'ᵰ', 'ᵱ', 'ᵲ', 'ᵳ', 'ᵴ', 'ᵵ', 'ᵶ', 'ᵺ', 'ᵻ', 'ᵽ', 'ᵾ', 'ᶀ', 'ᶁ', 'ᶂ', 'ᶃ', 'ᶄ', 'ᶅ', 'ᶆ', 'ᶇ', 'ᶈ', 'ᶉ', 'ᶊ', 'ᶌ', 'ᶍ', 'ᶎ', 'ᶏ', 'ᶑ', 'ᶒ', 'ᶓ', 'ᶖ', 'ᶙ', 'ẚ', 'ẜ', 'ẝ', 'ẞ', 'Ỻ', 'ỻ', 'Ỽ', 'ỽ', 'Ỿ', 'ỿ', '©', '®', '₠', '₢', '₣', '₤', '₧', '₺', '₹', 'ℌ', '℞', '㎧', '㎮', '㏆', '㏗', '㏞', '㏟', '¼', '½', '¾', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅛', '⅜', '⅝', '⅞', '⅟', '〇', '‘', '’', '‚', '‛', '“', '”', '„', '‟', '′', '″', '〝', '〞', '«', '»', '‹', '›', '‐', '‑', '‒', '–', '—', '―', '︱', '︲', '﹘', '‖', '⁄', '⁅', '⁆', '⁎', '、', '。', '〈', '〉', '《', '》', '〔', '〕', '〘', '〙', '〚', '〛', '︑', '︒', '︹', '︺', '︽', '︾', '︿', '﹀', '﹑', '﹝', '﹞', '⦅', '⦆', '。', '、', '×', '÷', '−', '∕', '∖', '∣', '∥', '≪', '≫', '⦅', '⦆']

TRANSLIT_TO

TRANSLIT_TO = ['AE', 'D', 'O', 'TH', 'ss', 'ae', 'd', 'o', 'th', 'D', 'd', 'H', 'h', 'i', 'q', 'L', 'l', 'L', 'l', '\'n', 'N', 'n', 'OE', 'oe', 'T', 't', 'b', 'B', 'B', 'b', 'C', 'c', 'D', 'D', 'D', 'd', 'E', 'F', 'f', 'G', 'hv', 'I', 'I', 'K', 'k', 'l', 'N', 'n', 'OI', 'oi', 'P', 'p', 't', 'T', 't', 'T', 'V', 'Y', 'y', 'Z', 'z', 'DZ', 'Dz', 'dz', 'G', 'g', 'd', 'Z', 'z', 'l', 'n', 't', 'j', 'db', 'qp', 'A', 'C', 'c', 'L', 'T', 's', 'z', 'B', 'U', 'E', 'e', 'J', 'j', 'R', 'r', 'Y', 'y', 'b', 'c', 'd', 'd', 'e', 'j', 'g', 'g', 'G', 'h', 'h', 'i', 'I', 'l', 'l', 'l', 'm', 'n', 'n', 'N', 'OE', 'r', 'r', 'r', 'R', 's', 't', 'u', 'v', 'Y', 'z', 'z', 'B', 'G', 'H', 'j', 'L', 'q', 'dz', 'dz', 'ts', 'ls', 'lz', 'A', 'AE', 'B', 'C', 'D', 'D', 'E', 'J', 'K', 'L', 'M', 'O', 'P', 'T', 'U', 'V', 'W', 'Z', 'ue', 'b', 'd', 'f', 'm', 'n', 'p', 'r', 'r', 's', 't', 'z', 'th', 'I', 'p', 'U', 'b', 'd', 'f', 'g', 'k', 'l', 'm', 'n', 'p', 'r', 's', 'v', 'x', 'z', 'a', 'd', 'e', 'e', 'i', 'u', 'a', 's', 's', 'SS', 'LL', 'll', 'V', 'v', 'Y', 'y', '(C)', '(R)', 'CE', 'Cr', 'Fr.', 'L.', 'Pts', 'TL', 'Rs', 'x', 'Rx', 'm/s', 'rad/s', 'C/kg', 'pH', 'V/m', 'A/m', ' 1/4', ' 1/2', ' 3/4', ' 1/3', ' 2/3', ' 1/5', ' 2/5', ' 3/5', ' 4/5', ' 1/6', ' 5/6', ' 1/8', ' 3/8', ' 5/8', ' 7/8', ' 1/', '0', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))']

PREG_PATTERN_ORDER

PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER

PREG_SET_ORDER

PREG_SET_ORDER = \PREG_SET_ORDER

PREG_OFFSET_CAPTURE

PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE

PREG_UNMATCHED_AS_NULL

PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL

PREG_SPLIT

PREG_SPLIT = 0

PREG_SPLIT_NO_EMPTY

PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY

PREG_SPLIT_DELIM_CAPTURE

PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE

PREG_SPLIT_OFFSET_CAPTURE

PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE

Properties

$string

$string

$ignoreCase

$ignoreCase

$transliterators

$transliterators

Methods

fromCodePoints()

fromCodePoints(int  ...$codes) : static

Parameters

int $codes variadic

Returns

static —

ascii()

ascii(string[]|\Transliterator[]|\Closure[]  $rules = []) : self

Generic UTF-8 to ASCII transliteration.

Install the intl extension for best results.

Parameters

string[]|\Transliterator[]|\Closure[] $rules

See "*-Latin" rules from Transliterator::listIDs()

Returns

self —

camel()

camel() : static

Returns

static —

codePointsAt()

codePointsAt(int  $offset) : int[]

Parameters

int $offset

Returns

int[] —

folded()

folded() : static

Returns

static —

join()

join(array  $strings, string  $lastGlue = null) : static

Parameters

array $strings
string $lastGlue

Returns

static —

lower()

lower() : static

Returns

static —

match()

match(string  $regexp, int  $flags, int  $offset) : array

Matches the string using a regular expression.

Pass PREG_PATTERN_ORDER or PREG_SET_ORDER as $flags to get all occurrences matching the regular expression.

Parameters

string $regexp
int $flags
int $offset

Returns

array —

All matches in a multi-dimensional array ordered according to flags

normalize()

normalize(int  $form = self::NFC) : static

Parameters

int $form

Returns

static —

padBoth()

padBoth(int  $length, string  $padStr = ' ') : static

Parameters

int $length
string $padStr

Returns

static —

padEnd()

padEnd(int  $length, string  $padStr = ' ') : static

Parameters

int $length
string $padStr

Returns

static —

padStart()

padStart(int  $length, string  $padStr = ' ') : static

Parameters

int $length
string $padStr

Returns

static —

replaceMatches()

replaceMatches(string  $fromRegexp, mixed  $to) : static

Parameters

string $fromRegexp
mixed $to

Returns

static —

reverse()

reverse() : static

Returns

static —

snake()

snake() : static

Returns

static —

title()

title(bool  $allWords = false) : static

Parameters

bool $allWords

Returns

static —

trim()

trim(string  $chars = " 	

 ") : static

Parameters

string $chars

Returns

static —

trimEnd()

trimEnd(string  $chars = " 	

 ") : static

Parameters

string $chars

Returns

static —

trimStart()

trimStart(string  $chars = " 	

 ") : static

Parameters

string $chars

Returns

static —

upper()

upper() : static

Returns

static —

width()

width(bool  $ignoreAnsiDecoration = true) : int

Returns the printable length on a terminal.

Parameters

bool $ignoreAnsiDecoration

Returns

int —

__construct()

__construct(string  $string = '') : mixed

Parameters

string $string

Returns

mixed —

unwrap()

unwrap(array  $values) : string[]|array

Unwraps instances of AbstractString back to strings.

Parameters

array $values

Returns

string[]|array —

wrap()

wrap(array  $values) : static[]|array

Wraps (and normalizes) strings in instances of AbstractString.

Parameters

array $values

Returns

static[]|array —

after()

after(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

afterLast()

afterLast(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

append()

append(string  ...$suffix) : \Symfony\Component\String\AbstractString

Parameters

string $suffix variadic

Returns

\Symfony\Component\String\AbstractString —

before()

before(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

beforeLast()

beforeLast(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

bytesAt()

bytesAt(int  $offset) : int[]

Parameters

int $offset

Returns

int[] —

chunk()

chunk(int  $length = 1) : array

Parameters

int $length

Returns

array —

collapseWhitespace()

collapseWhitespace() : static

Returns

static —

containsAny()

containsAny(string|string[]  $needle) : bool

Parameters

string|string[] $needle

Returns

bool —

endsWith()

endsWith(mixed  $suffix) : bool

Parameters

mixed $suffix

Returns

bool —

ensureEnd()

ensureEnd(string  $suffix) : static

Parameters

string $suffix

Returns

static —

ensureStart()

ensureStart(string  $prefix) : static

Parameters

string $prefix

Returns

static —

equalsTo()

equalsTo(mixed  $string) : bool

Parameters

mixed $string

Returns

bool —

ignoreCase()

ignoreCase() : static

Returns

static —

indexOf()

indexOf(mixed  $needle, int  $offset) : ?int

Parameters

mixed $needle
int $offset

Returns

?int —

indexOfLast()

indexOfLast(mixed  $needle, int  $offset) : ?int

Parameters

mixed $needle
int $offset

Returns

?int —

isEmpty()

isEmpty() : bool

Returns

bool —

jsonSerialize()

jsonSerialize() : string

Returns

string —

length()

length() : int

Returns

int —

prepend()

prepend(string  ...$prefix) : \Symfony\Component\String\AbstractString

Parameters

string $prefix variadic

Returns

\Symfony\Component\String\AbstractString —

repeat()

repeat(int  $multiplier) : static

Parameters

int $multiplier

Returns

static —

replace()

replace(string  $from, string  $to) : \Symfony\Component\String\AbstractString

Parameters

string $from
string $to

Returns

\Symfony\Component\String\AbstractString —

slice()

slice(int  $start, int  $length = null) : \Symfony\Component\String\AbstractString

Parameters

int $start
int $length

Returns

\Symfony\Component\String\AbstractString —

splice()

splice(string  $replacement, int  $start, int  $length = null) : \Symfony\Component\String\AbstractString

Parameters

string $replacement
int $start
int $length

Returns

\Symfony\Component\String\AbstractString —

split()

split(string  $delimiter, int  $limit = null, int  $flags = null) : array

Parameters

string $delimiter
int $limit
int $flags

Returns

array —

startsWith()

startsWith(mixed  $prefix) : bool

Parameters

mixed $prefix

Returns

bool —

toByteString()

toByteString(string  $toEncoding = null) : \Symfony\Component\String\ByteString

Parameters

string $toEncoding

Returns

\Symfony\Component\String\ByteString —

toCodePointString()

toCodePointString() : \Symfony\Component\String\CodePointString

Returns

\Symfony\Component\String\CodePointString —

toString()

toString() : string

Returns

string —

toUnicodeString()

toUnicodeString() : \Symfony\Component\String\UnicodeString

Returns

\Symfony\Component\String\UnicodeString —

truncate()

truncate(int  $length, string  $ellipsis = '', bool  $cut = true) : static

Parameters

int $length
string $ellipsis
bool $cut

Returns

static —

wordwrap()

wordwrap(int  $width = 75, string  $break = "
", bool  $cut = false) : static

Parameters

int $width
string $break
bool $cut

Returns

static —

__sleep()

__sleep() : array

Returns

array —

__clone()

__clone() : mixed

Returns

mixed —

__toString()

__toString() : string

Returns

string —

__wakeup()

__wakeup() : mixed

Returns

mixed —

pad()

pad(int  $len, self  $pad, int  $type) : static

Parameters

int $len
self $pad
int $type

Returns

static —

wcswidth()

wcswidth(string  $string) : int

Based on https://github.com/jquast/wcwidth, a Python implementation of https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c.

Parameters

string $string

Returns

int —