Skip to content

Instantly share code, notes, and snippets.

@LQ80
Forked from TheAhmedGad/utf8_arabic_ci.md
Created March 8, 2020 08:45
Show Gist options
  • Save LQ80/b8132fe08bba4076605f0a5eb85efe0e to your computer and use it in GitHub Desktop.
Save LQ80/b8132fe08bba4076605f0a5eb85efe0e 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