Converts a string from one charset to another.
Works only if either the iconv or the mbstring extension are present and best if both are available. The original string is returned if conversion failed or none of the extensions were available.
mixed
convertCharset
(mixed $input, string $from, [string $to = null])
-
mixed
$input: The data to be converted. If $input is an an array, the array's values get converted recursively.
-
string
$from: The string's current charset.
-
string
$to: The charset to convert the string to. If not specified, the global variable $_HORDE_STRING_CHARSET will be used.
Caches the result of extension_loaded() calls.
boolean
extensionExists
(string $ext)
-
string
$ext: The extension name.
Returns true if the every character in the parameter is an alphabetic character.
boolean
isAlpha
($string $string, [$charset $charset = null])
-
$string
$string: The string to test.
-
$charset
$charset: The charset to use when testing the string.
Returns true if ever character in the parameter is a lowercase letter in the current locale.
boolean
isLower
($string $string, [$charset $charset = null])
-
$string
$string: The string to test.
-
$charset
$charset: The charset to use when testing the string.
Returns true if every character in the parameter is an uppercase letter in the current locale.
boolean
isUpper
(string $string, [string $charset = null])
-
string
$string: The string to test.
-
string
$charset: The charset to use when testing the string.
Returns the character (not byte) length of a string.
string
length
(string $string, [string $charset = null])
-
string
$string: The string to return the length of.
-
string
$charset: The charset to use when calculating the string's length.
Makes a string lowercase.
string
lower
(string $string, [boolean $locale = false], [string $charset = null])
-
string
$string: The string to be converted.
-
boolean
$locale: If true the string will be converted based on a given charset, locale independent else.
-
string
$charset: If $locale is true, the charset to use when converting. If not provided the current charset.
Returns a string padded to a certain length with another string.
This method behaves exactly like str_pad but is multibyte safe.
string
pad
(string $input, integer $length, [string $pad = ' '], [const $type = STR_PAD_RIGHT], [string $charset = null])
-
string
$input: The string to be padded.
-
integer
$length: The length of the resulting string.
-
string
$pad: The string to pad the input string with. Must be in the same charset like the input string.
-
const
$type: The padding type. One of STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH.
-
string
$charset: The charset of the input and the padding strings.
Returns the numeric position of the first occurrence of $needle in the $haystack string.
integer
pos
(string $haystack, string $needle, [integer $offset = 0], [string $charset = null])
-
string
$haystack: The string to search through.
-
string
$needle: The string to search for.
-
integer
$offset: Allows to specify which character in haystack to start searching.
-
string
$charset: The charset to use when searching for the $needle string.
Performs a multibyte safe regex match search on the text provided.
array
regexMatch
(string $text, array $regex, [string $charset = null])
-
string
$text: The text to search.
-
array
$regex: The regular expressions to use, without perl regex delimiters (e.g. '/' or '|').
-
string
$charset: The character set of the text.
Sets a default charset that the String:: methods will use if none is explicitly specified.
void
setDefaultCharset
(string $charset)
-
string
$charset: The charset to use as the default one.
Returns part of a string.
string
substr
(string $string, integer $start, [integer $length = null], [string $charset = null])
-
string
$string: The string to be converted.
-
integer
$start: The part's start position, zero based.
-
integer
$length: The part's length.
-
string
$charset: The charset to use when calculating the part's position and length, defaults to current charset.
Returns a string with the first letter capitalized if it is alphabetic.
string
ucfirst
(string $string, [boolean $locale = false], [string $charset = null])
-
string
$string: The string to be capitalized.
-
boolean
$locale: If true the string will be converted based on a given charset, locale independent else.
-
string
$charset: The charset to use, defaults to current charset.
Makes a string uppercase.
string
upper
(string $string, [boolean $locale = false], [string $charset = null])
-
string
$string: The string to be converted.
-
boolean
$locale: If true the string will be converted based on a given charset, locale independent else.
-
string
$charset: If $locale is true, the charset to use when converting. If not provided the current charset.
Wraps the text of a message.
string
wordwrap
(string $string, [integer $width = 75], [string $break = "\n"], [boolean $cut = false], [string $charset = null], [boolean $line_folding = false])
-
string
$string: String containing the text to wrap.
-
integer
$width: Wrap the string at this number of characters.
-
string
$break: Character(s) to use when breaking lines.
-
boolean
$cut: Whether to cut inside words if a line can't be wrapped.
-
string
$charset: Character set to use when breaking lines.
-
boolean
$line_folding: Whether to apply line folding rules per RFC 822 or similar. The correct break characters including leading whitespace have to be specified too.
Wraps the text of a message.
string
wrap
(string $text, [integer $length = 80], [string $break_char = "\n"], [string $charset = null], [boolean $quote = false])
-
string
$text: String containing the text to wrap.
-
integer
$length: Wrap $text at this number of characters.
-
string
$break_char: Character(s) to use when breaking lines.
-
string
$charset: Character set to use when breaking lines.
-
boolean
$quote: Ignore lines that are wrapped with the '>' character (RFC 2646)? If true, we don't remove any padding whitespace at the end of the string.