Dear friends,
I've done an upgrade:
1. MySQL 4.0->5.0
2. PHP 4.3 -> 5.1
3. Drupal 4.6.8 -> 4.7.3
The problem looks simple: all content in russian is not readable anymore!
All the content is stored now in the table with the default encoding utf8.
A query "SELECT nid, title FROM node_revisions WHERE nid=13" passed through the client program 'mysql' returns what is expected: utf8-encoded title.
Now let's see node 13 in browser: magically everithyng gets cipherred. It looks very like the data are treated as latin1 or something like this and encoded to utf8 again by PHP or Drupal.
Where this dramatic second encoding takes place?
WBR, Andrei.
Comments
Thinking a bit more
Both php5 and MySQL5 were installed before Drupal's update. With 4.6.8 everything worked fine.
It means that it is Drupal who does the second encoding conversion.
The trouble catched!
Dear All,
In my case the trouble appeared at the moment of a silent upgrade of MySQL server to 5.0 version.
In fact, the data in tables after this upgrade can appear only with wrong MySQL configuration, which is default for 'mysql' client program and for Drupal 4.6.5, namely:
It means, that client (Drupal) sends latin1 encoded data, which shouldn't be decoded by server. Database is latin1 by default. Server is latin1 by default. Replies should be encoded in latin1!
This situation is changed in Drupal 4.7. It sets all these variables properly, and server sends what it keeps in the tables. It is the reason why I saw "twice encoded data".
Well, solution I found follows.
Take wrongly-encoded tables and dump them wrong way:
note --default-character-set=latin1 option, which is intentionally wrong.
Check, if you have got utf8 data in drupal.sql. Anyhow, probably using
Now replace all occurences of 'latin1' string by 'utf8' in drupal.sql, using text editor of your choice and feed the data back to the server:
Now you have correctly encoded tables.
You can check this, using mysql, for example:
If your console fonts are koi8-r, then you should see correct characters.
If you are using Drupal 4.6 then your pages will appear incorrect. Add string
in file includes/database.mysql.inc, to function db_connect() just before the return statement.
Now it should work.