forum.coppermine-gallery.net
Support => cpg1.4.x Support => Older/other versions => cpg1.4 language => Topic started by: sard on June 05, 2009, 02:43:39 pm
-
Hi,
Becuase my native language is one of Cyrillic group of languages, albums, categories, and some files are writtein with cyrillic charset. Their view (utf-8) in browser is ok, but in database even utf-8 is selected they are unreadable. If i write them in database with cyrillic letters then opposite they become unreadable in browser show of the gallery. Can you tell me how to show the both sides, databes and gallery in browser with proper cyrillic charset.
Thank you
-
Use cyrillic or unicode collation for your database as well. Not sure what you mean: how do you access the database? You'll need a tool that makes sure that the database content doesn't display "garbled", as you can't directly look at the database.
-
I use phpmyadmin. All charset through phpmyadmin are set to utf8_unicode_ci. Still everything cyrillic is unreadable (nonmeaningfull). If i write them in cyrillic then they stay ok, but opposite they become unreadable (nonmeaningfull) in gallery (browser) with the same supstitute characters.
-
I have same problems with the Russian language :(
If I put the Russian text using coppermine interface, I am getting database records in phpmyadmin looks like you are viewing UTF-8 using CP1251 codepage. I.e. if I type "Галерея улик e-mafia", I am getting "Ралерея улик e-mafia" in the phpmyadmin. If I change value in the phpmyadmin, I am getting like "������� ���� e-mafia" in the coppermine.
MySQL charset: UTF-8 Unicode (utf8)
MySQL connection collation: utf8_unicode_ci
The same problem I am getting the trying to bridge coppermine to phpBB 2.0.18, all users, who have Russian names displayed with ���� characters in Coppermine :(.
-
Sorry forget to add information about mysql and phpmyadmin versions:
Server version: 4.1.22-log
MySQL client version: 4.1.22
phpMyAdmin - 2.11.9.5
Used PHP extensions: mysql
-
http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616
-
I found the reason of this:
Looks like webhoster set up mysql to get out data by default in the CP1251 encoding. I.e. character_set_client='cp1251', character_set_results='cp1251', character_set_connection='cp1251'.
I solve this problem by adding "SET NAMES 'utf8'" query to the cpg_db_connect function in functions.inc.php
function cpg_db_connect()
{
global $CONFIG;
$result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
if (!$result) {
return false;
}
if (!mysql_select_db($CONFIG['dbname']))
return false;
mysql_query("SET NAMES 'utf8'", $result);
return $result;
}
I think instead of 'utf8', i should put the variable, responsible in Coppermine for Character encoding.
But I don't know it's name, and looks like it is stored in database, so results might be unpredictable.
-
Jaguar13, your solution is totally amazing and helped me resolve a long, long search.
Hint for all phpmyadmin users stuck with charset display problems who already have checked the collation settings of their own database and its tables:
This hack does not only apply to Cyrillic characters and not only to your particular provider.
Thank you very much!
-
I think instead of 'utf8', i should put the variable, responsible in Coppermine for Character encoding.
But I don't know it's name, and looks like it is stored in database, so results might be unpredictable.
The variable is $CONFIG['charset']
However, I can see another issue: I'm not sure that all webhosted users will have permission on database level to perform the SET NAMES query.
@devs: do you think that this should be added to the core? What happens if a user doesn't have permission to execute that query?
-
Thank you for solution.
-
Common policies: Resolve your threads (http://forum.coppermine-gallery.net/index.php/topic,55415.msg270631.html#msg270631)