Skip to content

Instantly share code, notes, and snippets.

@beshoo
Forked from TheAhmedGad/utf8-arabic-ci.md
Created May 2, 2021 02:30
Show Gist options
  • Save beshoo/00783c9694b64ba627fce75837f240f0 to your computer and use it in GitHub Desktop.
Save beshoo/00783c9694b64ba627fce75837f240f0 to your computer and use it in GitHub Desktop.
Add Arabic utf8 arabic ci Collation to MYSQL ENGINE

Support Arabic CI Collation

To make mysql understand Arabic letters synonyms like "أ" and "إ"

  • Run This to get Collation Path SHOW VARIABLES LIKE 'character_sets_dir';

  • in /collation/path/Index.xml add this to <charset name="utf8"> section

    <collation name="utf8_arabic_ci" id="1029">
        <rules>
            <reset>\u0627</reset>   <!-- Alef 'ا' -->
            <i>\u0623</i>           <!-- Alef With Hamza Above 'أ' -->
            <i>\u0625</i>           <!-- Alef With Hamza Below 'إ' -->
            <i>\u0622</i>           <!-- Alef With Madda Above 'آ' -->
        </rules>
        <rules>
            <reset>\u0629</reset>   <!-- Teh Marbuta 'ة' -->
            <i>\u0647</i>           <!-- Heh 'ه' -->
        </rules>
        <rules>
            <reset>\u064A</reset>   <!-- 'ي' -->
            <i>\u0649</i>           <!-- 'ى' -->
            <i>\u0626</i>           <!-- 'ئ' -->
        </rules>
        <rules>
            <reset>\u0648</reset>   <!-- 'و' -->
            <i>\u0624</i>           <!-- 'ؤ' -->
        </rules>
        <rules>
            <reset>\u0000</reset>   <!-- Unicode value of NULL  -->
            <i>\u064E</i>           <!-- Fatha 'َ' -->
            <i>\u064F</i>           <!-- Damma 'ُ' -->
            <i>\u0650</i>           <!-- Kasra 'ِ' -->
            <i>\u0651</i>           <!-- Shadda 'ّ' -->
            <i>\u064F</i>           <!-- Sukun 'ْ' -->
            <i>\u064B</i>           <!-- Fathatan 'ً' -->
            <i>\u064C</i>           <!-- Dammatan 'ٌ' -->
            <i>\u064D</i>           <!-- Kasratan 'ٍ' -->
        </rules>
    </collation>
    
    
  • restart mysql sudo service mysql restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment