How can I change extended latin characters to their unaccented ASCII equivalents?

前端 未结 5 1485
萌比男神i
萌比男神i 2021-01-18 09:50

I need a generic transliteration or substitution regex that will map extended latin characters to similar looking ASCII characters, and all other extended characters to \'\'

5条回答
  •  一生所求
    2021-01-18 10:34

    Use Unicode::Normalize to get the NFD($str). In this form all the characters with diacritics will be turned into a base character followed by a combining diacritic character. Then simply remove all the non-ASCII characters.

提交回复
热议问题