UTF-8 support? UTF-8 support?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

UTF-8 support?

Started by giorgio79, February 11, 2007, 07:31:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

giorgio79

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?

Nibbler

You can add that into cpg_db_connect in include/functions.inc.php but you really shouldn't need to.

giorgio79

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 :)

Nibbler

What are you checking using? Is that set to display unicode?

giorgio79

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.

giorgio79

I think the issue lies maybe at the connection or client charset, UTF8 has to be set maybe at 6-8 places  :o

giorgio79

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

giorgio79

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