Rev. 2009-07-06

How I got b2evolution to work in both English and Russian with UTF-8

I wanted to start a blog that contains both English and Russian characters. It might occasionally use other Unicode characters, so UTF-8 seeemed the best character set. I also wanted to use open source software, and because I had previously played with it briefly, I chose b2evolution. Getting it to work right was much trickier than the forum postings on had led me to believe. In fact it took about a week of headcracking, and that was even with the help of some kind forum members. Here's a detailed account of how I got it to work.

Before you do anything else, you will need a webspace host that provides PHP scripting and MySQL. I use, and frankly I've been entirely happy with them. They provide phpMyAdmin for some of the MySQL manipulation.

  1. I made a new MySQL 5.0 database on my web host, using charset UTF-8 Unicode (utf8) and chose utf8_general_ci as the MySQL connection collation.
  2. I downloaded and unzipped it on my computer.
  3. I replaced these values in conf/_basic_config.php
    $db_config = array(
    	'user'          => 'dbo#######',            // your MySQL username
    	'password'      => 'mypasswordhere',        // ...and password
    	'name'          => 'db########',            // the name of the database
    	'host'          => '',    // MySQL Server (typically 'localhost')
    with my username, password, etc. All those hash marks (#) I replaced with the appropriate numbers for my account.
  4. I replaced these two lines in conf/_locales.php
    $force_io_charset_if_accepted = '';
    $db_config['connection_charset'] = '';
    $force_io_charset_if_accepted = 'utf-8';
    $db_config['connection_charset'] = 'utf8';
  5. I added a line immediately inside the <head> section of skins/
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    I added that because the blog wouldn't render for one of my viewers and this resolved his issue.
  6. I got the fixcharset.php script from and put it in directory install/ on my computer. Then I searched through the file for every sequence starting with YOUR and substituted my username, password, etc. There are four places that you have to make changes, one of which is later in the file.
  7. I uploaded the entire blogs/ directory and all its subdirectories into my webspace.
  8. I entered http://mydomainname/blogs/install/ into my browser window. I verified that the MySQL values looked good, added my e-mail address in the appropriate field, and then clicked the Update config file. Then I clicked the Go button for a new install. From the bottom of the page I noted down the admin name and password for later, but I did not login yet to b2evolution.
  9. I entered http://mydomainname/blogs/install/fixcharset.php into my browser window and let it run.
  10. The fixcharset.php script was not quite as thorough as a beginner might hope, so I fired up phpMyAdmin, opened the database, and I adjusted the collation sequence to utf8_general_ci for the following tables/columns:
  11. At this stage everything was working correctly. Now there are a couple anal retentive items that should be attended to. It's bad habit to post to a blog under the admin account, so I did the following.
  12. While still logged in as admin, I made a new user as part of the Privileged blogger user group.
  13. While still logged in as admin, under Blog settings/List I made a new standard blog whose owner was the user I made in the last step.
  14. Under Global settings/General I set Default blog to display to the blog I made in the last step.

That's it. As you can see, the process wasn't trivial, but it worked on the whole.

The modifications mentioned above worked on the whole, but they left a defect: the notification messages that were sent to the author of a posting when a comment was made on the post did not correctly display Russian. I have still not been able to fix the subject lines of those messages, but I have successfully enabled Russian in the body of those messages. This is a hack, but it works so far. The following changes had to be made in \inc\_core\_misc.funcs.php:


My changes

I inserted this line before the next Content-Type line:

$headers['MIME-Version'] = '1.0' ;
$headers['Content-Type'] = 'text/plain; charset='.$current_charset; $headers['Content-Type'] = 'text/plain; charset=UTF-8' ;
$subject = mb_encode_mimeheader( $subject, mb_internal_encoding(), 'B', $NL ); $subject = mb_encode_mimeheader( $subject, 'UTF-8', 'B', $NL );
I actually don't think this change did any good.
$message = convert_charset( $message, $current_charset, $evo_charset ); I commented this line out. The databases are all in UTF-8, so no converstion should be necessary.