MySQL and cp1251 entries ...

Discussion corner for Developers of Serendipity.
Post Reply
JWalker
Regular
Posts: 177
Joined: Mon Sep 12, 2005 4:14 pm
Location: Botevgrad, Bulgaria
Contact:

MySQL and cp1251 entries ...

Post by JWalker »

Hello,

I did experiments on another PC with this configuration:
Windows XP SP1 / Apache 2.0.55 / PHP 5.1.2 / MySQL 5.0.18 / s9y_200601251437.tar.gz .

I installed MySQL in C:\MySQL.
mysql.ini:

Code: Select all

[mysql]

default-character-set=cp1251
.....
[mysqld]
default-character-set=cp1251
...
The confguratrion of serendipity:
Apache mod_rewrite,
Bulgarian language
Native (not UTF-8!!)

user settings: Bulgarian language.

What happened:

I was able to enter entries in English (latin letters).
When I tried to enter an entry that has Cyrillic letters in the title or in the body, this error occurs, and it is MySQL error:

Code: Select all

Грешка:

INSERT INTO serendipity_entries (title,timestamp,body,extended,isdraft,allow_comments,moderate_comments,exflag,comments,last_modified,author,authorid) values ('България', '1138212885', 'Български', '', 'false', 'true', 'false', '0', '0', '1138212885', 'imc', '1')

/ Data too long for column 'title' at row 1
Even one cyrillic letter is sufficient to generate this error. It is obvious that data is NOT too long indeed.

This does not happen with my 'official' installation with MySQL 4.1.14/ PHP 5.0.2.

Then I tried with the MySQL command-line client and another database (not s9y) and saw this error when entering cyrillic fields. set names 'cp1251' made this error to not occur.

I realize that I could make errors there, but if not this may be a hint for s9y improvement. This is why I posted here in 'Development' and not in 'Bugs' or 'General issues'.

Regards,
Ivan Cenov
OKTO-7 Co., Botevgrad
Bulgaria
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: MySQL and cp1251 entries ...

Post by garvinhicking »

You are absolutely right. Support for this is missing, but can be changed by using the MySQL5 default utf8 set and/or changing MySQL to always enforce the utf8/cp1251 client encoding. But I agree this is too hard.

I've added a bug item on SF.net, and will include a patch for this after Serendipity 1.0 final. I am too afraid that this will break existing things and thus don't want it in the 1.0 release.

Many thanks,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: MySQL and cp1251 entries ...

Post by garvinhicking »

I've just committed a patch, where this should work if you add

$serendipity['dbNames'] = TRUE;

within your serendipity_config_local.inc.php file. For the next s9y version, this will be the default.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
JWalker
Regular
Posts: 177
Joined: Mon Sep 12, 2005 4:14 pm
Location: Botevgrad, Bulgaria
Contact:

it works

Post by JWalker »

Meanwhile, I made new fresh, installation, utf8 this time, even said in my.ini default-character-set = utf8. Then selected utf8 / Bulgarian in s9y configuration and now all is OK and as expected.

I played this game to see how to move my existing blog/entries to new php/MySQL installation whenever decide to upgrade.

And I agree, the beta time is not the right time for so deep changes.

Regards,
Ivan Cenov
OKTO-7 Co., Botevgrad
Bulgaria
Post Reply