class UtfString implements ArrayAccess, Stringable (View source)

Implementation for UTF-8 strings.

The subscript operator in PHP, when used with string will return a byte and not a character. Because in UTF-8 strings a character may occupy more than one byte, the subscript operator may return an invalid character.

Because the lexer relies on the subscript operator this class had to be implemented.

Implements array-like access for UTF-8 strings.

In this library, this class should be used to parse UTF-8 queries.

Properties

string $str

The raw, multi-byte string.

int $byteIdx

The index of current byte.

int $charIdx

The index of current character.

int $byteLen

The length of the string (in bytes).

int $charLen

The length of the string (in characters).

Methods

__construct(string $str)

No description

bool
offsetExists(mixed $offset)

Checks if the given offset exists.

string|null
offsetGet(mixed $offset)

Gets the character at given offset.

void
offsetSet(mixed $offset, mixed $value)

Sets the value of a character.

void
offsetUnset(mixed $offset)

Unsets an index.

int
length()

Returns the length in characters of the string.

string
__toString()

Returns the contained string.

Details

__construct(string $str)

No description

Parameters

string $str

the string

bool offsetExists(mixed $offset)

Checks if the given offset exists.

Parameters

mixed $offset

the offset to be checked

Return Value

bool

string|null offsetGet(mixed $offset)

Gets the character at given offset.

Parameters

mixed $offset

the offset to be returned

Return Value

string|null

void offsetSet(mixed $offset, mixed $value)

Sets the value of a character.

Parameters

mixed $offset

the offset to be set

mixed $value

the value to be set

Return Value

void

Exceptions

Exception

void offsetUnset(mixed $offset)

Unsets an index.

Parameters

mixed $offset

the value to be unset

Return Value

void

Exceptions

Exception

int length()

Returns the length in characters of the string.

Return Value

int

string __toString()

Returns the contained string.

Return Value

string