Bug #79788 Turlish dotless ı collates strangely
Submitted: 28 Dec 2015 19:57 Modified: 24 Jan 2018 3:49
Reporter: Rick James Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:5.6, 5.6.28 OS:Any
Assigned to: CPU Architecture:Any
Tags: collation

[28 Dec 2015 19:57] Rick James
Description:
In most utf8/utf8mb4 collations (other than utf8_turkish_ci and utf8_bin), I=i=İ, but ı is not treated as the same.  That lowercase dotless I seems to be treated as a separate letter, between I and J.

For utf8_turkish_ci, this seems reasonable:

+------------+
| Equivalent |
+------------+
| I=ı        |
| i=İ        |
+------------+

For utf8_general_ci, this seems reasonable:

+------------+
| Equivalent |
+------------+
| I=i=İ=ı    |
+------------+

For other collations, it seems 'wrong':

+------------+
| Equivalent |
+------------+
| I=i=İ      |
| ı          |
+------------+

For reference, here are the hex values:

+------+--------+
| c    | hex(c) |
+------+--------+
| i    | 69     |
| I    | 49     |
| ı    | C4B1   |
| İ    | C4B0   |
+------+--------+

(I am not a linguist, but this seems wrong.)

How to repeat:
CREATE TABLE Dotless (
    c CHAR(1) CHARACTER SET utf8
);

INSERT INTO Dotless (c) VALUES ('i'),('I'),('ı'),('İ');

SELECT GROUP_CONCAT(c ORDER BY HEX(c) SEPARATOR '=')  AS Equivalent
    FROM Dotless
    GROUP BY c          COLLATE utf8_turkish_ci;
SELECT GROUP_CONCAT(c ORDER BY HEX(c) SEPARATOR '=')  AS Equivalent
    FROM Dotless
    GROUP BY c          COLLATE utf8_general_ci;
SELECT GROUP_CONCAT(c ORDER BY HEX(c) SEPARATOR '=')  AS Equivalent
    FROM Dotless
    GROUP BY c          COLLATE utf8_unicode_ci;
SELECT GROUP_CONCAT(c ORDER BY HEX(c) SEPARATOR '=')  AS Equivalent
    FROM Dotless
    GROUP BY c          COLLATE utf8_unicode_520_ci;

# The `ORDER BY HEX(c)` is makes the 'equal' chars come out in a canonical order

Suggested fix:
I suspect this 'bug' (if it is such) should be nothing more than a footnote, especially after the fiasco with utf8_german_ci and the sharp-s.

I did not notice any other anomalies like this in the collations.  (I doubt if 'ƒ' qualifies as an accented 'f'.)

This bug was prompted by this forum thread:
http://stackoverflow.com/questions/34462887/how-to-find-all-variations-accented-etc-of-a-s...
[29 Dec 2015 9:36] MySQL Verification Team
Hello Rick,

Thank you for the report and test case.
Verified as described with 5.6.28 build.

Thanks,
Umesh
[24 Jan 2018 3:49] Xing Zhang
Posted by developer:
 
utf8_unicode_ci and utf8_unicode_520_ci (and the new utf8mb4 collations like utf8mb4_0900_ai_ci) are implemented based on UCA. UCA thanks that U+0131 (LATIN SMALL LETTER DOTLESS I) has different base letter from characters like U+0049), so they have different primary weight and not equal when comparing.