Search code examples
phpcodeigniternon-ascii-characters

This Codeigniter function doesn't account for all accented characters


This is a list of accented characters I have found here.

ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ

I have used the Codeigniter function convert_accented_characters to convert accented characters to ASCII characters. However, it seems to fail for two characters (Þ and þ), see output:

AAAeAAAAECEEEEIIIIDjNOOOOOeOUUUUeYÞssaaaaaeaaeceeeeiiiidjnoooooeouuuueyþy

How can I extend this array to account for these two characters.

Would this change be adequate?

'/п/Þ/þ' => 'p', at line 88? I am not familiar with those characters and what language they are from!


Solution

  • You should add this code

    '/Þ|þ/' => 'th',
    '/п/' => 'p',
    

    to the array in file application/config/foreign_chars.php

    This array is used to define transliteration

    Þ or þ are coming from the Icelandic alphabets. Are replaced with the digraph th in english

    п is from Cyrillic alphabet and translate in english as p