Instead of specifically writing string manipulation code that is multibyte-safe, e.g. mb_substr() instead of substr(), you can configure PHP to do this automatically. Just update the following lines in your php.ini.
mbstring.internal_encoding = UTF-8
mbstring.func_overload = 7
mbstring.strict_detection = On
zend.multibyte = On
zend.script_encoding = UTF-8
mbstring.func_overload will automatically cause any non-multibyte-safe functions to use their multibyte-safe counterparts.