Recent Topics

SOLVED: Japanese-independent utf8 problem with mysql 4.1.x

Started by on Apr 16, 2006 – Contents updated: Apr 16, 2006

Apr 16, 2006 00:33    

As many knows mysql 4.1.x handles multibyte-characters in a special way. So b2evolution, which handles Japanese in utf-8 has a problem with them. Anyone tries to hack it?

I knew phpBB with EUC-JP (ujis) could be 4.1x-enabled by setting mysql_query("SET CHRACTER SET ujis;", (connectid)), and I tried a similarway to set it to utf8 in b2evolution just after connecting to mysql server, but in vain. My problem is I'm using ujis on the same machine. So I need to use 2 codes. Fortunately mysql 4.0.x does it well.

Does anyone have hints on it? Or if possible, I with b2evolution supported EUC-JP (ujis) instead utf8.....

Apr 17, 2006 07:42

maverick wrote:

As many knows mysql 4.1.x handles multibyte-characters in a special way. So b2evolution, which handles Japanese in utf-8 has a problem with them. Anyone tries to hack it?

I knew phpBB with EUC-JP (ujis) could be 4.1x-enabled by setting mysql_query("SET CHRACTER SET ujis;", (connectid)), and I tried a similarway to set it to utf8 in b2evolution just after connecting to mysql server, but in vain. My problem is I'm using ujis on the same machine. So I need to use 2 codes. Fortunately mysql 4.0.x does it well.

Does anyone have hints on it? Or if possible, I with b2evolution supported EUC-JP (ujis) instead utf8.....

Self-reply. I found a solution.

I suspect other languages using utf8 also suffer from this one. The fix mentioned above worked also for b2evolution!! My fixes are in 3 places in 2 files as follows (in diff -C3 -r format against version 0.9.1).

diff -r -C3 b2evolution.bak/blogs/b2evocore/_class_db.php b2evolution/blogs/b2evocore/_class_db.php
*** b2evolution.bak/blogs/b2evocore/_class_db.php       Fri Sep  2 23:31:34 2005--- b2evolution/blogs/b2evocore/_class_db.php   Mon Apr 17 14:02:39 2006
***************
*** 183,188 ****
--- 183,189 ----

                // Connect to the Database:
                $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);
+ mysql_query("SET CHARACTER SET utf8;", $this->dbh);

                if( ! $this->dbh )
                {
diff -r -C3 b2evolution.bak/extras/geeklog/gl2evo.php b2evolution/extras/geeklog/gl2evo.php
*** b2evolution.bak/extras/geeklog/gl2evo.php   Tue Sep 13 16:11:10 2005
--- b2evolution/extras/geeklog/gl2evo.php       Mon Apr 17 14:02:00 2006
***************
*** 60,70 ****
--- 60,72 ----
  // Connect to the databases
  $db_gl = mysql_connect($gl_dbhost,$gl_dbuser,$gl_dbpass);
  if (!$db_gl) die('Could not connect: ' . mysql_error());
+ mysql_query("SET CHARACTER SET utf8;", $db_gl);
  $gl_sel = mysql_select_db($gl_database, $db_gl);
  if (!$gl_sel) die ('Can\'t use $gl_database : ' . mysql_error());

  $db_evo = mysql_connect($evo_dbhost,$evo_dbuser,$evo_dbpass);
  if (!$db_evo) die('Could not connect: ' . mysql_error());
+ mysql_query("SET CHARACTER SET utf8;", $db_evo);
  $evo_sel = mysql_select_db($evo_database, $db_evo);
  if (!$evo_sel) die ('Can\'t use $evo_database : ' . mysql_error());

These explicitly tell mysql server what kind of character code b2evolution uses. And at the same time, the collation of the database for b2evolution must be set properly (in my case utf8). And this works for me in Japanese utf8 and isn't Japanese specific, though I haven't tested with other languages..

Jul 05, 2006 08:58

Maverick,

Where is the gl2evo.php files? Did you create these?

I just migrated servers and all my Japanese is screwed (bakemoji) up and I cannot write to B2 in Japanese (posts are all garbled). Hopefully your solution will help...

Thanks,

Jeff

Jul 08, 2006 21:08

Jeff,
It's in b2evolution/extras/geeklog from the beginning. from b2evolution-0.9.1b-2005-09-16.zip.

Jul 10, 2006 03:13

Maverick,

Thanks for you help. I tried your solution and it works if I write directly to the database through PhpMyAdmin. Through PhpMyAdmin it displays correctly, but if I put a post through the b2 admin, it shows up as all question marks.

This whole problem started when I moved servers so I am not sure what is NOT supporting utf-8 on the new server.

Any other ideas?

Thanks,

Jeff

Sep 30, 2006 23:44

I have been unable to make b2e display Japanese correctly. My English installation allows messages to display correctly in Japanese; however if the blog is set to Japanese the interface displays incorrect characters. And a Japanese installation displays the interface correctly, but messages display as question marks.

Is there a definitive solution for this?

Mike Lyons

Oct 01, 2006 06:30

Make sure your English charset is set to utf-8 in the back office. By default it is not set to utf-8 so you will need to change it.

Let me know if it works

May 17, 2007 14:39

I'm having trouble using Japanese. It turns out all ???s. I would like to try the following code out but I'm a complete novice... How do you use it? Is it through phpMyAdmin? And if so, what do I do once I'm in phpMyAdmin? I know this is kind of an old thread but I hope someone can get back to me...

Thanks!

maverick wrote:

maverick wrote:

As many knows mysql 4.1.x handles multibyte-characters in a special way. So b2evolution, which handles Japanese in utf-8 has a problem with them. Anyone tries to hack it?

I knew phpBB with EUC-JP (ujis) could be 4.1x-enabled by setting mysql_query("SET CHRACTER SET ujis;", (connectid)), and I tried a similarway to set it to utf8 in b2evolution just after connecting to mysql server, but in vain. My problem is I'm using ujis on the same machine. So I need to use 2 codes. Fortunately mysql 4.0.x does it well.

Does anyone have hints on it? Or if possible, I with b2evolution supported EUC-JP (ujis) instead utf8.....

Self-reply. I found a solution.

I suspect other languages using utf8 also suffer from this one. The fix mentioned above worked also for b2evolution!! My fixes are in 3 places in 2 files as follows (in diff -C3 -r format against version 0.9.1).

diff -r -C3 b2evolution.bak/blogs/b2evocore/_class_db.php b2evolution/blogs/b2evocore/_class_db.php
*** b2evolution.bak/blogs/b2evocore/_class_db.php       Fri Sep  2 23:31:34 2005--- b2evolution/blogs/b2evocore/_class_db.php   Mon Apr 17 14:02:39 2006
***************
*** 183,188 ****
--- 183,189 ----

                // Connect to the Database:
                $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);
+ mysql_query("SET CHARACTER SET utf8;", $this->dbh);

                if( ! $this->dbh )
                {
diff -r -C3 b2evolution.bak/extras/geeklog/gl2evo.php b2evolution/extras/geeklog/gl2evo.php
*** b2evolution.bak/extras/geeklog/gl2evo.php   Tue Sep 13 16:11:10 2005
--- b2evolution/extras/geeklog/gl2evo.php       Mon Apr 17 14:02:00 2006
***************
*** 60,70 ****
--- 60,72 ----
  // Connect to the databases
  $db_gl = mysql_connect($gl_dbhost,$gl_dbuser,$gl_dbpass);
  if (!$db_gl) die('Could not connect: ' . mysql_error());
+ mysql_query("SET CHARACTER SET utf8;", $db_gl);
  $gl_sel = mysql_select_db($gl_database, $db_gl);
  if (!$gl_sel) die ('Can\'t use $gl_database : ' . mysql_error());

  $db_evo = mysql_connect($evo_dbhost,$evo_dbuser,$evo_dbpass);
  if (!$db_evo) die('Could not connect: ' . mysql_error());
+ mysql_query("SET CHARACTER SET utf8;", $db_evo);
  $evo_sel = mysql_select_db($evo_database, $db_evo);
  if (!$evo_sel) die ('Can\'t use $evo_database : ' . mysql_error());

These explicitly tell mysql server what kind of character code b2evolution uses. And at the same time, the collation of the database for b2evolution must be set properly (in my case utf8). And this works for me in Japanese utf8 and isn't Japanese specific, though I haven't tested with other languages..

Nov 29, 2007 02:18

Hmm, I've been on MySQL 4.1 and writing Japanese for a while. I haven't had many problems with it. I basically just had to mark the tables and fields as being in UTF-8. You also need to make sure as jeffposaka said that your blog's language setting is set to utf-8.

That said, I do sometimes get the issue that lotek is describing that causes posts to be rendered with ?s instead of the actual characters. It seems to only happen sometimes and generally corrects itself if I cause the posts to be rerendered so I haven't spent much time trying to figure out the cause.


Form is loading...

Photo gallery software – This forum is powered by b2evolution CMS, a complete engine for your website.