^Status|First Draft|
^Todo|Expand, fill in missing methods|
====== Unicode Functions ======
Provides static methods to work with UTF-8 strings as PHP is not yet natively capable of doing that.
Requirements:
* [[http://php.net/pcre|PCRE]] needs to be compiled with UTF-8 support.
* The [[http://php.net/iconv|iconv extension]] needs to be loaded.
* The [[http://php.net/mbstring|mbstring extension]] is highly recommended. However, it must not be overloading string functions.
===== Methods =====
==== clean ====
''utf8::clean()'' recursively cleans arrays, objects, and strings. It removes ASCII control characters (''[[utf8#strip_ascii_ctrl|strip_ascii_ctrl]]'') and converts to UTF-8 while silently discarding incompatible UTF-8 characters.
var_dump(utf8::is_ascii("a\0b".chr(127).'c')); // bool(true)
var_dump(utf8::is_ascii("a\0b".chr(128).'c')); // bool(false)
==== ltrim ====
==== ord ====
==== rtrim ====
==== str_ireplace ====
==== str_pad ====
==== str_split ====
==== strcasecmp ====
==== strcspn ====
==== strip_ascii_ctrl ====
''utf8::strip_ascii_ctrl()'' removes all [[wp>ASCII#ASCII_control_characters|ASCII control characters]] from a string.
**Example:**
echo utf8::strip_ascii_ctrl("a\0b".chr(7).'c');
// Output: abc
==== strip_non_ascii ====
''utf8::strip_non_ascii()'' removes all non-ASCII characters from a string.
**Example:**
echo utf8::strip_non_ascii('Clichés');
// Output: Clichs
==== stristr ====
==== strlen ====
==== strpos ====
==== strrev ====
==== strrpos ====
==== strspn ====
==== strtolower ====
==== strtoupper ====
==== substr ====
==== substr_replace ====
==== to_unicode ====
==== transliterate_to_ascii ====
''utf8::transliterate_to_ascii()'' replaces many (not all) special/accented characters by their ASCII equivalents. Special characters that are unknown to this method are left untouched. You can remove them afterwards with the ''[[utf8#strip_non_ascii|strip_non_ascii]]'' method.
**Example:**
echo utf8::transliterate_to_ascii('Jérôme est un garçon.');
// Output: Jerome est un garcon.
Further reading: [[wp>Transliteration|Wikipedia on transliteration]]
==== trim ====
==== ucfirst ====
==== ucwords ====
<< [[core:kohana|Kohana]] : Previous