This is documentation for Kohana v2.3.x. For v3.x documentation, see http://kohanaframework.org/guide .
|Todo||Expand, fill in missing methods|
Provides static methods to work with UTF-8 strings as PHP is not yet natively capable of doing that.
utf8::clean() recursively cleans arrays, objects, and strings. It removes ASCII control characters (
strip_ascii_ctrl) and converts to UTF-8 while silently discarding incompatible UTF-8 characters.
clean() method is automatically applied to the GET, POST, COOKIE and SERVER globals.
utf8::is_ascii() checks whether a string contains only 7bit ASCII bytes. It returns TRUE if it does so, FALSE otherwise.
This method is also used internally in the utf8 class to determine when to use native functions or UTF-8 functions.
utf8::strip_ascii_ctrl() removes all ASCII control characters from a string.
utf8::strip_non_ascii() removes all non-ASCII characters from a string.
echo utf8::strip_non_ascii('Clichés'); // Output: Clichs
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
echo utf8::transliterate_to_ascii('Jérôme est un garçon.'); // Output: Jerome est un garcon.
Further reading: Wikipedia on transliteration
« Kohana : Previous