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
Properties
- $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<int, StringWrapperInterface>>|null
- Ordered list of registered string wrapper instances
Methods
- 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
$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']
$wrapperRegistry
Ordered list of registered string wrapper instances
protected
static array<int, StringWrapperInterface>>|null
$wrapperRegistry
Methods
getRegisteredWrappers()
Get registered wrapper classes
public
static getRegisteredWrappers() : array<string|int, string>
Tags
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
Return values
StringWrapperInterfacehasPcreUnicodeSupport()
Is PCRE compiled with Unicode support?
public
static hasPcreUnicodeSupport() : bool
Return values
boolisSingleByteEncoding()
Check if a given encoding is a known single-byte character encoding
public
static isSingleByteEncoding(string $encoding) : bool
Parameters
- $encoding : string
Return values
boolisValidUtf8()
Check if a given string is valid UTF-8 encoded
public
static isValidUtf8(string $str) : bool
Parameters
- $str : string
Return values
boolregisterWrapper()
Register a string wrapper class
public
static registerWrapper(StringWrapperInterface> $wrapper) : void
Parameters
- $wrapper : StringWrapperInterface>
resetRegisteredWrappers()
Reset all registered wrappers so the default wrappers will be used
public
static resetRegisteredWrappers() : void
unregisterWrapper()
Unregister a string wrapper class
public
static unregisterWrapper(StringWrapperInterface> $wrapper) : void
Parameters
- $wrapper : StringWrapperInterface>