How to Convert Non-English Characters to English Using JavaScript

前端 未结 4 1235
野性不改
野性不改 2021-01-19 10:52

I have a c# function which converts all non-english characters to proper characters for a given text. like as follows

public static string convertString(stri         


        
4条回答
  •  迷失自我
    2021-01-19 11:21

    Although this is an old question, this is a problem I face frequently. I therefore wrote a tutorial on how to solve it. It's located here: http://nicoschuele.com/Posts/75.html

    The short answer is this: first, you need to treat all the diacritical characters within a function and then, using a dictionnary you build, you need to process all the language specific letters. For example, "à" is a diacritical character and "Ø" is a norwegian letter. My tutorial uses .NET to achieve this but the principle, even in javascript, is the same.

提交回复
热议问题