Advanced search  

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

Pages: [1]   Go Down

Author Topic: UTF-8 support?  (Read 3546 times)

0 Members and 1 Guest are viewing this topic.

giorgio79

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
UTF-8 support?
« 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 )
      {

Code: [Select]
    $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?
Logged

Nibbler

  • Guest
Re: UTF-8 support?
« Reply #1 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.
Logged

giorgio79

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
Re: UTF-8 support?
« Reply #2 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 :)
Logged

Nibbler

  • Guest
Re: UTF-8 support?
« Reply #3 on: February 11, 2007, 09:51:22 pm »

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

giorgio79

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
Re: UTF-8 support?
« Reply #4 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.
Logged

giorgio79

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
Re: UTF-8 support?
« Reply #5 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
Logged

giorgio79

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
Re: UTF-8 support?
« Reply #6 on: February 12, 2007, 08:21:31 am »

Yeah it worked for me!
I added this code

Code: [Select]
$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:

Code: [Select]
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
Logged

giorgio79

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 114
Re: UTF-8 support?
« Reply #7 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
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 20 queries.