PHP - utf-8 strings handling

Enable mbstring function overloading mode and set default encoding for string functions to utf-8 in php.ini:

mbstring.internal_encoding = UTF-8
mbstring.func_overload = 7

These settings allow us to use “usual” php string functions like substr() for utf-8 strings. It is not recommended to set function overloading in per-directory context (via Apache config or in the .htaccess).

Default encoding can also be set using mb_internal_encoding function:

mb_internal_encoding('UTF-8');

Or encoding can be set explicitly as argument in mbstring function:

$sub = mb_substr($mbstr, 0, 1, 'utf-8');

PHP Docs - Multibyte String

Yii Wiki - How to set up Unicode

profile for Boris Serebrov on Stack Exchange, a network of free, community-driven Q&A sites