Add unicode support to preg_replace

The 'u' flag for preg_replace means the pattern and subject strings are treated as UTF-8.