MySQL Forums :: Character Sets, Collation, Unicode :: Can someone please explain this misbehavior?


Advanced Search

Can someone please explain this misbehavior?
Posted by: A B ()
Date: August 19, 2014 07:53PM

SET `collation_connection` = 'utf8_bin';
SET @wrong = CONVERT(CAST(0xD187D0B5D180D0BDD18BD0B9 AS CHAR) USING 'cp1251') COLLATE 'cp1251_general_ci';
SET @right = CONVERT(CAST(0xD187D191D180D0BDD18BD0B9 AS CHAR) USING 'cp1251') COLLATE 'cp1251_general_ci';
SELECT @wrong AS `wrong`, @right AS `right`,
IF(@wrong = @right, 'Bogus comparison', 'Right is right') AS `equality`;


versus

SET `collation_connection` = 'utf8_bin';
SET @wrong = CONVERT(CAST(0xD187D0B5D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_general_ci';
SET @right = CONVERT(CAST(0xD187D191D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_general_ci';
SELECT @wrong AS `wrong`, @right AS `right`,
IF(@wrong = @right, 'Bogus comparison', 'Right is right') AS `equality`,
@@collation_connection AS `collation`;

SET `collation_connection` = 'utf8_bin';
SET @wrong = CONVERT(CAST(0xD187D0B5D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_unicode_ci';
SET @right = CONVERT(CAST(0xD187D191D180D0BDD18BD0B9 AS CHAR) USING 'utf8') COLLATE 'utf8_unicode_ci';
SELECT @wrong AS `wrong`, @right AS `right`,
IF(@wrong = @right, 'Bogus comparison', 'Right is right') AS `equality`,
@@collation_connection AS `collation`;

Options: ReplyQuote


Subject Views Written By Posted
Can someone please explain this misbehavior? 1796 A B 08/19/2014 07:53PM
Re: Can someone please explain this misbehavior? 865 Rick James 08/20/2014 07:23PM
Re: Can someone please explain this misbehavior? 886 A B 08/20/2014 08:15PM
Re: Can someone please explain this misbehavior? 1035 Rick James 08/21/2014 05:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.