system/core/utf8.php
Class: utf8
final class utf8
Methods
- utf8 :: clean
- utf8 :: is_ascii
- utf8 :: strip_ascii_ctrl
- utf8 :: strip_non_ascii
- utf8 :: transliterate_to_ascii
- utf8 :: strlen
- utf8 :: strpos
- utf8 :: strrpos
- utf8 :: substr
- utf8 :: substr_replace
- utf8 :: strtolower
- utf8 :: strtoupper
- utf8 :: ucfirst
- utf8 :: ucwords
- utf8 :: strcasecmp
- utf8 :: str_ireplace
- utf8 :: stristr
- utf8 :: strspn
- utf8 :: strcspn
- utf8 :: str_pad
- utf8 :: str_split
- utf8 :: strrev
- utf8 :: trim
- utf8 :: ltrim
- utf8 :: rtrim
- utf8 :: ord
- utf8 :: to_unicode
- utf8 :: from_unicode
utf8 :: clean
public static function clean
Recursively cleans arrays, objects, and strings. Removes ASCII control codes and converts to UTF-8 while silently discarding incompatible UTF-8 characters.
Parameters:
- string str
- string to clean
Return: string
utf8 :: is_ascii
public static function is_ascii
Tests whether a string contains only 7bit ASCII bytes. This is used to determine when to use native functions or UTF-8 functions.
Parameters:
- string str
- string to check
Return: bool
utf8 :: strip_ascii_ctrl
public static function strip_ascii_ctrl
Strips out device control codes in the ASCII range.
Parameters:
- string str
- string to clean
Return: string
utf8 :: strip_non_ascii
public static function strip_non_ascii
Strips out all non-7bit ASCII bytes.
Parameters:
- string str
- string to clean
Return: string
utf8 :: transliterate_to_ascii
public static function transliterate_to_ascii
Replaces special/accented UTF-8 characters by ASCII-7 'equivalents'.
Parameters:
- string str
- string to transliterate
- integer case
- (int 0) -1 lowercase only, +1 uppercase only, 0 both cases
Return: string
utf8 :: strlen
public static function strlen
Returns the length of the given string.
Parameters:
- string str
- string being measured for length
See: http://php.net/strlen
Return: integer
utf8 :: strpos
public static function strpos
Finds position of first occurrence of a UTF-8 string.
Parameters:
- string str
- haystack
- string search
- needle
- integer offset
- (int 0) offset from which character in haystack to start searching
See: http://php.net/strlen
Return:
- integer position of needle
- boolean FALSE if the needle is not found
utf8 :: strrpos
public static function strrpos
Finds position of last occurrence of a char in a UTF-8 string.
Parameters:
- string str
- haystack
- string search
- needle
- integer offset
- (int 0) offset from which character in haystack to start searching
See: http://php.net/strrpos
Return:
- integer position of needle
- boolean FALSE if the needle is not found
utf8 :: substr
public static function substr
Returns part of a UTF-8 string.
Parameters:
- string str
- input string
- integer offset
- offset
- integer length
- (NULL) length limit
See: http://php.net/substr
Return: string
utf8 :: substr_replace
public static function substr_replace
Replaces text within a portion of a UTF-8 string.
Parameters:
- string str
- input string
- string replacement
- replacement string
- integer offset
- offset
- length
- (NULL)
See: http://php.net/substr_replace
Return: string
utf8 :: strtolower
public static function strtolower
Makes a UTF-8 string lowercase.
Parameters:
- string str
- mixed case string
See: http://php.net/strtolower
Return: string
utf8 :: strtoupper
public static function strtoupper
Makes a UTF-8 string uppercase.
Parameters:
- string str
- mixed case string
See: http://php.net/strtoupper
Return: string
utf8 :: ucfirst
public static function ucfirst
Makes a UTF-8 string's first character uppercase.
Parameters:
- string str
- mixed case string
See: http://php.net/ucfirst
Return: string
utf8 :: ucwords
public static function ucwords
Makes the first character of every word in a UTF-8 string uppercase.
Parameters:
- string str
- mixed case string
See: http://php.net/ucwords
Return: string
utf8 :: strcasecmp
public static function strcasecmp
Case-insensitive UTF-8 string comparison.
Parameters:
- string str1
- string to compare
- string str2
- string to compare
See: http://php.net/strcasecmp
Return:
- integer less than 0 if str1 is less than str2
- integer greater than 0 if str1 is greater than str2
- integer 0 if they are equal
utf8 :: str_ireplace
public static function str_ireplace
Returns a string or an array with all occurrences of search in subject (ignoring case). replaced with the given replace value.
Parameters:
- string or array search
- text to replace
- string or array replace
- replacement text
- string or array str
- subject text
- integer count
- (NULL) number of matched and replaced needles will be returned via this parameter which is passed by reference
See: http://php.net/str_ireplace
Note: It's not fast and gets slower if $search and/or $replace are arrays.