Multibyte String Errors

Monday, June 11th, 2012

While creating this WordPress blog  I ran into some difficulties installing the theme for this website. I was trying to install it on a new VPS and I was getting the following errors from two PHP files in the theme folder.

After much Googling I came across the following solution, which only resolved the error in the files that were causing the error. By replacing the lines that were causing the problems (functions.php line 12 and misc.php line 21) with the code shown below, it had the undesired effect of then producing other sets of errors in other files which also had different multibyte functions, such as mb_strlen.

I eventually discovered that the problem may in fact lie with the PHP settings on my server. So after more research (Googling) I tried using the “PHP configuration editor” in the Service Configuration section of my WHM, to set the mb_internal_encoding value to UTF-8, but still got the errors. The solution was to recompile Apache using WHM.   So if you are using WHM then try the following:

  1. Go to the Software section
  2. Find EasyApache
  3. Make sure Previously Saved Config (** DEFAULT **)  is selected
  4. Choose “Start customising based on profile”
  5. You can skip through the steps to reach step 5
  6. From there enable mbstring and recompile Apache
  7. Wait about 50 minutes (that’s how long it took for me)

Obviously the steps above will only work if you have access to WHM, if you are using a shared hosting package you may need to contact your hosting provider and ask if they can enable mbstring for you. Hope this advice helps and saves you some pain, as the mbstring functions can be called in many plugins, not just themes. For a full list and more information on  mbstring functions you can check out the PHP manual http://www.php.net/manual/en/book.mbstring.php.

Tags: , , , , , ,