Extras

What Transliteration Does

Transliteration is the process of swapping letters from one script to another. The substitutions are based on the characters that are displayed to make the words more readable (they are not phonetic–based on sounds). For example:

LanguageCharacterTransliterated
French é e
Greek α a
Cyrillic д d

Why Transliterate?

URLs only support ASCII characters (the letters A–z, numbers 0–9 and a few other special characters), so websites perform transliteration on URLs if they may contain non-ASCII characters.

They might need to do this if a site's URLs are based on article titles or member's names.

OriginalTransliterated
http://eg.link/café http://eg.link/cafe
http://eg.link/München http://eg.link/Munchen
http://eg.link/Αθήνα http://eg.link/Athena
http://eg.link/北京 http://eg.link/bei-jing
http://eg.link/Россия http://eg.link/Rossia

How to Transliterate

Below, PHP's transliterate_transliterate() function, will replace the non-ASCII characters in $string with the nearest corresponding ASCII character.

To use the function, you must have the Internationalization extension (also referred to as intl) installed on your web server. You can see how to check if it is installed below.

transliterate_transliterate('Any-Latin; Latin-ASCII;'$string)
   
FunctionConvert to ASCIIString

How to Check if the Internationalization Extension is Running

Temporarily add the phpinfo() function to a page on your site.

View the page to see information about your version of PHP.

Look under the heading intl.

Remove the phpinfo() function from the page.

If it is running, then the first row will say enabled.

If it is not running, turn it on in php.ini by removing the semicolon before the setting extension=intl.