Note: This is only true if we actually care for the value of collation_connection, i.e. if we're ever comparing literal strings (as opposed to strings from database columns). So, if we ever had a *good* reason to use SET CHARACTER SET, we need to keep using it or set collation_connection explicitly. Otherwise, SET NAMES will be enough.
-Matthias On Wed, Jul 20, 2011 at 21:31, Matthias Bauer <[email protected]> wrote: > Now, with more time, allow me to elaborate: > > ==== > > A `SET NAMES 'x'` statement is equivalent to these three statements: > > SET character_set_client = x; > SET character_set_results = x; > SET character_set_connection = x; > > [...] > > A `SET CHARACTER SET x` statement is equivalent to these three statements: > > SET character_set_client = x; > SET character_set_results = x; > SET collation_connection = @@collation_database; > > ==== > > So, either one of those is not enough. `SET NAMES` does not set > collation_connection, and `SET CHARACTER SET` does not set a *given* > character_set_connection, but uses the database's collation. So, we > need SET CHARACTER SET followed by SET NAMES, or we can just send a > bunch of "SET ... = ..." statements. > > -Matt > > On Wed, Jul 20, 2011 at 19:38, Chris Meller <[email protected]> wrote: >> If switching those two fixes your problem it means that the database you're >> using for Habari on your MySQL server is not set to a good encoding (like >> UTF8), it's probably using the default latin1 instead. >> >> >> >> The only time that's a problem is in this exact situation. SET CHARACTER SET >> sets the collation for the database connection to whatever is being used by >> the database you're talking to. If that's not also utf8 then MySQL butchers >> the data and bad things happen. >> >> >> >> Re-reading the MySQL docs it looks like we don't actually need SET CHARACTER >> SET, SET NAMES covers everything we want and uses the character set we tell >> it to, rather than whatever the database is set to. I'll make the needed >> change momentarily, but I don't know when we'll next package up a release... >> >> >> >> -----Original Message----- >> From: "Philip Buckley" <[email protected]> >> Sent: Tuesday, July 19, 2011 9:22pm >> To: "habari-dev" <[email protected]> >> Subject: [habari-dev] Re: UTF8 Input >> >> Thanks, Andrew, I don't think in this case it is the browser's >> encoding - I'm using Firefox and UTF-8 is checked as the character >> encoding, but ... >> >> *A minute or two later* >> >> ... Oh! I've just found this post by Matthias Bauer <http:// >> groups.google.com/group/habari-dev/browse_thread/thread/ >> 111b719fc097eeec/b4e3d31a8edf8c25?lnk=gst&q=UTF-8#b4e3d31a8edf8c25> >> >> and his suggestion works for me ... I have swapped lines 31 and 32 of >> schema > mysql > connection.php so that they now are: >> >> $this->exec('SET CHARACTER SET ' . MYSQL_CHAR_SET); >> $this->exec('SET NAMES ' . MYSQL_CHAR_SET); >> >> i.e. the "SET NAMES" line comes after the "SET CHARACTER SET" line. >> >> I don't know why that makes a difference, and I don't like modifying >> system files, but I'm relieved if that proves to be all it takes (I'd >> better double-check my testing). >> >> Perhaps someone who understands this better than I might know why >> swapping the lines makes a difference, and if there is a good reason >> why they should be swapped, perhaps they should be swapped in the core >> code? >> >> Philip >> >> >> >> On Jul 20, 1:57 am, Andrew Heath <[email protected]> wrote: >>> I've successfully used Simplified Chinese on my installation. >>> >>> Perhaps your browser's encoding is not also set to Unicode? >>> >>> - A >>> >>> On Wed, Jul 20, 2011 at 8:52 AM, Philip Buckley >>> <[email protected]>wrote: >>> >>> >>> >>> >>> >>> >>> >>> > If I create a new entry and enter some Russian letters (cutting and >>> > pasting from a UTF8 text file or entering them manually), the letters >>> > show up correctly in the text area until I click Save, at which point >>> > they all turn to question marks. >>> >>> > I assume there is some problem putting the text into the database / >>> > reading it out? >>> >>> > Habari version is 0.7.1; Database is MySQL; OS is Mac >>> >>> > Any suggestions how to get round this? Any suggestions how to track >>> > down where the problem is arising? >>> >>> > Thanks >>> >>> > Philip >>> >>> > -- >>> > To post to this group, send email to [email protected] >>> > To unsubscribe from this group, send email to >>> > [email protected] >>> > For more options, visit this group at >>> >http://groups.google.com/group/habari-dev >> >> -- >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/habari-dev >> >> -- >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/habari-dev > -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/habari-dev
