FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » windows-1251 (Cyr) & MySQL 4.1
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
windows-1251 (Cyr) & MySQL 4.1 [message #32332] Wed, 21 June 2006 13:10 Go to next message
boroda is currently offline  boroda   Russian Federation
Messages: 8
Registered: September 2005
Karma: 0
Junior Member
It is rather feature then a bug, but the strange feature indeed.

since MySQL 4.1 we should set the charset while talking to the database. It seems that the FUDFORUM explicitly set this charset. But when we chose this Russian win-1251 language settings, this charset differs from cp1251 while talking to Database. It's look like latin with extended characters (swedish, or something like this). Everything is fine, because FUDFORUM makes the right conversion while taking data from the database. So we can read this characters form the browser.

BUT! I can read this data when browse tables by phpMyAdmin -- I can see only extended characters, but can read them as russians.

Generally may be it will be good decision to set the character set according to the language settings, while connecting to the database (say SET NAMES cp1251 for the russian win1251 language)?

Thank you.
Re: windows-1251 (Cyr) & MySQL 4.1 [message #32333 is a reply to message #32332] Wed, 21 June 2006 15:12 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
A single forum can use multiple languages while a table charset is for all data, so we have to use a neutral setting.

FUDforum Core Developer
Re: windows-1251 (Cyr) & MySQL 4.1 [message #32336 is a reply to message #32333] Wed, 21 June 2006 15:33 Go to previous messageGo to next message
boroda is currently offline  boroda   Russian Federation
Messages: 8
Registered: September 2005
Karma: 0
Junior Member
Ok. Reasonable solution.

But is it possible to use UTF-8 as the Language setting? I didn't found this option.

Thank you.
Re: windows-1251 (Cyr) & MySQL 4.1 [message #32343 is a reply to message #32336] Wed, 21 June 2006 18:27 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You can adjust the forum charset to use UTF-8 but I wouldn't recommend it.

FUDforum Core Developer
Re: windows-1251 (Cyr) & MySQL 4.1 [message #32352 is a reply to message #32343] Wed, 21 June 2006 19:40 Go to previous messageGo to next message
boroda is currently offline  boroda   Russian Federation
Messages: 8
Registered: September 2005
Karma: 0
Junior Member
Thank you for an answer
Re: windows-1251 (Cyr) & MySQL 4.1 [message #32441 is a reply to message #32333] Thu, 29 June 2006 07:51 Go to previous message
aigumnov   Russian Federation
Messages: 2
Registered: June 2006
Karma: 0
Junior Member
Ilia wrote on Wed, 21 June 2006 19:12

A single forum can use multiple languages while a table charset is for all data, so we have to use a neutral setting.


'Latin1' is not the neutral setting. Just a few notes to make it clear.
I think it works like follows:
1) By default, PHP is 'latin1' client. The PHP-app and MySQL server handshake this during mysql_connect. To note, later the 'handshaked' charset can be changed using 'SET NAMES' or 'SET CHARACTER SET'.
2) In this case, if the table's charset is 'latin1', the MySQL server compares 'client-charset-is-latin1'='table-charset-is-latin1' and turns off any text conversions on input. The effect of this trick is that any data records are stored without any transformation, 'as is'.
3) Then, while reading data, another php-script handshakes with MySQL using 'latin1' charset. Again, as client encoding matches server, no transformations 'on read' are made and 'Everything is fine, because FUDFORUM makes the right conversion while taking data from the database' (actually there is no conversion at all, everything is based on right webpage charset).

If you try to set another charset on client side using, for example, 'SET NAMES cp1251', the MySQL server decides to perform the conversion 'latin1'->'cp1251'. If your data in 'latin1' table are in 'cp1251', the conversion is actually lossy , and you'll get '?' and other garbled characters.

So, by default, phpMyAdmin can't display the data right, as recommended phpMyAdmin configuration sets the 'cp1251' charset.

To read any data stored in such tricky way, one must specify the 'client charset' matching 'table charset'. To read default FUDForum table structure using phpMyAdmin - just 'SET NAMES latin1' and it will read all data 'as is'.

This behaviour leads to more problems when somebody tries to manage the forum data outside the forum php application. For example, on russian Windows, the mysql commandline client uses cp866 charset (by default). The 'cp866'<->'cp1251' conversion is not lossy, however, if the data goes into 'latin1' table in 'cp866', and then such records came out as is (in 'cp866') on 'cp1251' webpage, making the changes unreadable.

Also, there are server configurations that may override this trick, and FUDForum will not work at all.

I don't know how will FUDForum work with Unicode (UTF-8) charsets in database, but if the one's forums are truly multilanguage, the UTF is the only option. All webpages must be Unicode, as it is impossible to have, for example, one message in Chinese and other in Russian simultaneously without Unicode webpages.

If the forums are single language (not 'latin1'), I personally think its worth to make some changes in server setup, and/or FUDForum configuration and source code. Just to make table structure more manageable and to match other data in database. The decision must be made by forum's owner/administrator.

[Updated on: Thu, 29 June 2006 08:52]

Report message to a moderator

  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Import from NNTP to forum
Next Topic: Out of range value adjusted for column icq
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 06:00:44 GMT 2024

Total time taken to generate the page: 0.02584 seconds