1
josez
db encoding
  • 2005/3/24 13:15

  • josez

  • Just popping in

  • Posts: 19

  • Since: 2005/2/11


hi. i have transferred my site from one hoster to another. the old DB uses encoding cp1250, but the new sql-server uses utf-8 by default so the texts from db now look wired.
i think, that problem is, that when XOOPS connects to db and asks for char-encoding the db says: utf8 and XOOPS uses utf8. is there a way to force XOOPS to use cp-1250 when connecting to DB?

..i'm not a php or MySQL expert, so maybe i am not right...

thanx in advance for your help.

2
ackbarr
Re: db encoding

I just had a look at the php MySQL documentation and it doesn't look like you can control the character set from PHP's side.

On the MySQL side it looks like you CAN send a query to the database telling it you will be communicating in character set x:

SET CHARACTER SET [i]x[/i]


You will need to confirm that the desired character set is available on the server by running this query (in phpmyadmin or some other MySQL console program)
SHOW CHARACTER SET;


If it is, you can try to set the character set immediately after the db connection has been initialized, in /includes/common.php:
after
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection();

add
$xoopsDB->query('SET CHARACTER SET ');

3
josez
Re: db encoding
  • 2005/3/24 16:26

  • josez

  • Just popping in

  • Posts: 19

  • Since: 2005/2/11


that didn§t work :(
when i try show character set i get the list and cp1250 is there. i tried to put also these commands to common.php right after the DB connection:
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection();
  
$xoopsDB->query('SET CHARACTER SET cp1250;'); 
  
$xoopsDB->query('SET character_set_client=cp1250;');
  
$xoopsDB->query('SET character_set_connection=cp1250;');
  
$xoopsDB->query('SET character_set_results=cp1250;');


on my site in language file global.php i have set character set to windows-1250.
when i post to forum, with characters like ľščťžýá (slovak) i get question marks and stupid characters in the post. but when i switch XOOPS to language, which uses utf8 encoding - everything works OK. but i would like to use cp1250, since my XOOPS translation is in this encoding and also the old database...

4
intel352
Re: db encoding
  • 2005/3/24 19:12

  • intel352

  • Module Developer

  • Posts: 824

  • Since: 2003/11/23


why not just alter the db character set?

http://dev.mysql.com/doc/mysql/en/charset-database.html

Login

Who's Online

352 user(s) are online (297 user(s) are browsing Support Forums)


Members: 0


Guests: 352


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits