sindresorhus / transliterate

Convert Unicode characters to Latin characters using transliteration
MIT License
290 stars 20 forks source link

Error in Arabic transliteration? ("i" should be "a"?) #9

Open danielweck opened 4 years ago

danielweck commented 4 years ago

Shouldn't the i in fact be an a?

    ['آ', 'a'],
    ['أ', 'a'],

    ['إ', 'i'],

    ['ا', 'a'],

You may run the following tests in your shell / Javascript console:

The base / non-accented "a":

["ا", "a"]

node -e "console.log('ا'.codePointAt(0).toString(16)); console.log('ا'.normalize('NFD').replace(/[\u0300-\u036f]/g, '').codePointAt(0).toString(16));" =>

627
627

First diacritic variant:

["أ", "a"]

node -e "console.log('أ'.codePointAt(0).toString(16)); console.log('أ'.normalize('NFD').replace(/[\u0300-\u036f]/g, '').codePointAt(0).toString(16));" =>

623
627

Second diacritic variant:

["آ", "a"]

node -e "console.log('آ'.codePointAt(0).toString(16)); console.log('آ'.normalize('NFD').replace(/[\u0300-\u036f]/g, '').codePointAt(0).toString(16));" =>

622
627

Third diacritic variant:

["إ", "i"]

node -e "console.log('إ'.codePointAt(0).toString(16)); console.log('إ'.normalize('NFD').replace(/[\u0300-\u036f]/g, '').codePointAt(0).toString(16));" =>

625
627

Why i, when 627 (same as all other variants) which resolves to a when mapped?

https://github.com/sindresorhus/transliterate/blob/master/replacements.js