coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: giorgio79 on February 11, 2007, 07:31:17 PM

Title: UTF-8 support?
Post by: giorgio79 on February 11, 2007, 07:31:17 PM
Hello,

I have just noticed that my Hungarian characters are stored incorrectly in the db. Even though they are displayed back right, and the db collation is UTF, and the character encoding as well.

I believe it has to do with the mysql connection, and I had a similar issue with phpbb.

I had to add the following lines added to mysql php right after
      if( $this->db_connect_id )
      {

    $result = mysql_query('SET character_set_client = utf8') or die('Query failed: ' . mysql_error());
    $result = mysql_query('SET character_set_results = utf8') or die('Query failed: ' . mysql_error());
    $result = mysql_query('SET character_set_connection = utf8') or die('Query failed: ' . mysql_error());


Is there a similar db connection file for coppermine?
Title: Re: UTF-8 support?
Post by: Nibbler on February 11, 2007, 08:30:45 PM
You can add that into cpg_db_connect in include/functions.inc.php but you really shouldn't need to.
Title: Re: UTF-8 support?
Post by: giorgio79 on February 11, 2007, 09:26:03 PM
Yeah, that is what I was hoping for, but when I check the db, I see such stuff:

Szakáll      shows as    Szakáll  in the db

Lépcső      shows as     lépcsÅ'  in the db

The special characters like ő, á, é, í all look ugly...

Even though they look right on the output, I would like to get them right everywhere....Will try to add that stuff in the db, and will let you know how it went :)
Title: Re: UTF-8 support?
Post by: Nibbler on February 11, 2007, 09:51:22 PM
What are you checking using? Is that set to display unicode?
Title: Re: UTF-8 support?
Post by: giorgio79 on February 11, 2007, 10:40:18 PM
I use phpmyadmin

the same characters display fine in my phpbb_users table, where I can see them for usernames...but in coppermine_pictures keywords and such, I see the garbage characters.
Title: Re: UTF-8 support?
Post by: giorgio79 on February 11, 2007, 10:42:05 PM
I think the issue lies maybe at the connection or client charset, UTF8 has to be set maybe at 6-8 places  :o
Title: Re: UTF-8 support?
Post by: giorgio79 on February 12, 2007, 08:21:31 AM
Yeah it worked for me!
I added this code

$utf = mysql_query('SET character_set_client = utf8') or die('Query failed: ' . mysql_error());
    $utf = mysql_query('SET character_set_results = utf8') or die('Query failed: ' . mysql_error());
    $utf = mysql_query('SET character_set_connection = utf8') or die('Query failed: ' . mysql_error());


Right after:

function cpg_db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);



Although I do not recommend this to those that have a lot of picture with garbage chars, as this will make the pages display exactly what is in  the db...

I am glad I could contribute my two pence for coppermine.

Cheers,

Gyuri
Title: Re: UTF-8 support?
Post by: giorgio79 on February 12, 2007, 08:37:48 AM
One last thing, for this to work, I had to alter the collation of the tables AND the columns as well to utf8_general_ci

Cheers,
Gyuri