forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: giorgio79 on May 14, 2007, 01:12:09 am

Title: displaying thumb title in UTF
Post by: giorgio79 on May 14, 2007, 01:12:09 am
Hi Guys,

I am using the cpm_getAlbumListFrom, and the thumb title seems to be messed up if the browser is set to display in UTF.

I am also storing in the cpg db the title of pics in UTF8.

Have any of you had this?

Cheers,
Gyuri
Title: Re: displaying thumb title in UTF
Post by: Nibbler on May 14, 2007, 02:16:02 am
A link might help.
Title: Re: displaying thumb title in UTF
Post by: giorgio79 on May 14, 2007, 08:21:55 am
Hi Nibbler!

Thanks for coming back. Check it out:

http://www.macadu.hu/test.php

Try changing the encoding to UTF-8 in the browser instead of one of the ISOs.

My cpg album handles fine the titles if the browser is set to UTF8, and my db is UTF8 as well...

I also noted that if the filename has UTF8 chars, like on my test, it cannot be displayed, although if you click on the errored message, cpg album displays it fine.

Cheers,
Gyuri
Title: Re: displaying thumb title in UTF
Post by: giorgio79 on May 14, 2007, 05:56:03 pm
Hi Nibbler,

I solved this.

I added three lines in the dbconnect function in the cpmfetch_dao.php, so that not only the db, and the display is UTF but the mysql connection as well. This is an old problem, that I first encountered in phpbb. Check out how it looks now, and the pic and the thumb descriptions are showing fine if browser is UTF. :)


here is what I did (see // MY MOD)

function dbConnect ( ) {
   if ($this->dbconnection == "") {

      if (version_compare(phpversion(), "4.2.0", ">=") &&
            strtolower($this->cfg['cfUseExistingDBConnection']) != "true") {
         $this->dbconnection = mysql_connect($this->cfg['dbserver'], $this->cfg['dbuser'], $this->cfg['dbpass'], true);
      } else {
         $this->dbconnection = mysql_connect($this->cfg['dbserver'], $this->cfg['dbuser'], $this->cfg['dbpass']);
      }
      mysql_select_db($this->cfg['dbname'], $this->dbconnection);
// MY MOD
      $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());
Title: Re: displaying thumb title in UTF
Post by: vuud on May 29, 2007, 11:05:04 pm
Hi Nibbler,

I solved this.

I added three lines in the dbconnect function in the cpmfetch_dao.php, so that not only the db, and the display is UTF but the mysql connection as well. This is an old problem, that I first encountered in phpbb. Check out how it looks now, and the pic and the thumb descriptions are showing fine if browser is UTF. :)


here is what I did (see // MY MOD)

function dbConnect ( ) {
   if ($this->dbconnection == "") {

      if (version_compare(phpversion(), "4.2.0", ">=") &&
            strtolower($this->cfg['cfUseExistingDBConnection']) != "true") {
         $this->dbconnection = mysql_connect($this->cfg['dbserver'], $this->cfg['dbuser'], $this->cfg['dbpass'], true);
      } else {
         $this->dbconnection = mysql_connect($this->cfg['dbserver'], $this->cfg['dbuser'], $this->cfg['dbpass']);
      }
      mysql_select_db($this->cfg['dbname'], $this->dbconnection);
// MY MOD
      $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());


Thank you for posting a solution.  I will have to see if I can work this directly into a future release.