UtfString
class UtfString implements ArrayAccess (View source)
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
No description
Checks if the given offset exists.
Gets the character at given offset.
Sets the value of a character.
Unsets an index.
Gets the length of an UTF-8 character.
Returns the length in characters of the string.
Returns the contained string.
Details
__construct(string $str)
bool
offsetExists(int $offset)
Checks if the given offset exists.
string|null
offsetGet(int $offset)
Gets the character at given offset.
offsetSet(int $offset, string $value)
Sets the value of a character.
offsetUnset(int $offset)
Unsets an index.
static int
getCharLength(string $byte)
Gets the length of an UTF-8 character.
According to RFC 3629, a UTF-8 character can have at most 4 bytes. However, this implementation supports UTF-8 characters containing up to 6 bytes.
int
length()
Returns the length in characters of the string.
string
__toString()
Returns the contained string.