How to Convert Special Chars to Standard Chars?

前端 未结 3 1303
天涯浪人
天涯浪人 2021-01-19 10:13

I\'m looking for way to convert chars like āžšķūņrūķīš to azskunrukis. In other words, to replace ā with a, ž with z an

3条回答
  •  旧时难觅i
    2021-01-19 10:37

    Take a look at iconv's transliteration capabilities:

    
    

    The above example will output something similar to:

    Original : This is the Euro symbol '€'.
    TRANSLIT : This is the Euro symbol 'EUR'.
    IGNORE : This is the Euro symbol ''.
    Plain :
    Notice: iconv(): Detected an illegal character in input string in .\iconv-example.php on line 7
    This is the Euro symbol '

    Your example text can be tranliterated using:

    $translit = iconv('UTF-8', 'US-ASCII//TRANSLIT', 'āžšķūņrūķīš');
    

    Here's an example with the text you provided: http://ideone.com/MJHvf

提交回复
热议问题