Proper PHP UTF-8 multi-byte operations

Have you ever tried handling UTF-8 strings in PHP and everything gets weird with a million questionmarks smashing you on the face? Make sure that you have set UTF-8 to be used by the multibyte PHP5 module as follows:

mb_internal_encoding(‘UTF-8’);
mb_regex_encoding(‘UTF-8’);

You may then use all usual multibyte functions:

// Word democracy in greek language. Returns 10.
mb_strlen(‘ΔΗΜΟΚΡΑΤΙΑ’);

Read more on http://php.net/manual/en/ref.mbstring.php

Software Software, IT Addicted. He has replaced his brain with CUDA cores. Try talking to him in 01010101.

Leave a Reply

Next ArticleHow to add a cPanel PHP cron job