FileAccess Orion

StringUtils
in package

Utility class for handling strings of different character encodings using available PHP extensions.

Declared abstract, as we have no need for instantiation.

Table of Contents

$hasPcreUnicodeSupport  : bool
Is PCRE compiled with Unicode support?
$singleByteEncodings  : array<string|int, string>
A list of known single-byte character encodings (upper-case)
$wrapperRegistry  : array<string|int, StringWrapperInterface>
Ordered list of registered string wrapper instances
getRegisteredWrappers()  : array<string|int, string>
Get registered wrapper classes
getSingleByteEncodings()  : array<string|int, string>
Get a list of all known single-byte character encodings
getWrapper()  : StringWrapperInterface
Get the first string wrapper supporting the given character encoding and supports to convert into the given convert encoding.
hasPcreUnicodeSupport()  : bool
Is PCRE compiled with Unicode support?
isSingleByteEncoding()  : bool
Check if a given encoding is a known single-byte character encoding
isValidUtf8()  : bool
Check if a given string is valid UTF-8 encoded
registerWrapper()  : void
Register a string wrapper class
resetRegisteredWrappers()  : void
Reset all registered wrappers so the default wrappers will be used
unregisterWrapper()  : void
Unregister a string wrapper class

Properties

$hasPcreUnicodeSupport

Is PCRE compiled with Unicode support?

protected static bool $hasPcreUnicodeSupport = null

$singleByteEncodings

A list of known single-byte character encodings (upper-case)

protected static array<string|int, string> $singleByteEncodings = ['ASCII', '7BIT', '8BIT', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 'CP-1251', 'CP-1252']

Methods

getRegisteredWrappers()

Get registered wrapper classes

public static getRegisteredWrappers() : array<string|int, string>
Return values
array<string|int, string>

getSingleByteEncodings()

Get a list of all known single-byte character encodings

public static getSingleByteEncodings() : array<string|int, string>
Return values
array<string|int, string>

getWrapper()

Get the first string wrapper supporting the given character encoding and supports to convert into the given convert encoding.

public static getWrapper([string $encoding = 'UTF-8' ][, string|null $convertEncoding = null ]) : StringWrapperInterface
Parameters
$encoding : string = 'UTF-8'

Character encoding to support

$convertEncoding : string|null = null

OPTIONAL character encoding to convert in

Tags
throws
RuntimeException

If no wrapper supports given character encodings

Return values
StringWrapperInterface

hasPcreUnicodeSupport()

Is PCRE compiled with Unicode support?

public static hasPcreUnicodeSupport() : bool
Return values
bool

isSingleByteEncoding()

Check if a given encoding is a known single-byte character encoding

public static isSingleByteEncoding(string $encoding) : bool
Parameters
$encoding : string
Return values
bool

isValidUtf8()

Check if a given string is valid UTF-8 encoded

public static isValidUtf8(string $str) : bool
Parameters
$str : string
Return values
bool

registerWrapper()

Register a string wrapper class

public static registerWrapper(string $wrapper) : void
Parameters
$wrapper : string
Return values
void

resetRegisteredWrappers()

Reset all registered wrappers so the default wrappers will be used

public static resetRegisteredWrappers() : void
Return values
void

unregisterWrapper()

Unregister a string wrapper class

public static unregisterWrapper(string $wrapper) : void
Parameters
$wrapper : string
Return values
void

Search results