Title: Converting ú to u in javascript
Tags: javascript;unicode;character-encoding
Question: How would I convert ú into u in javascript. I might possibly need it for other non-english characters too. 



Here is another answer: MovableType has a function called dirify that does that.  Here's a PHP version.  These are essentially big lookup tables, so it should be pretty easy to move them across to JavaScript.

In theory you could parse the Unicode tables and follow character references until you hit ASCII, but that might not be practical for you.


Here is another answer: A similar question has been asked (but in a .NET context): How do I remove diacritics (accents) from a string in .NET?

I think the simplest solution would be to make a mapping table and just do a lookup for each character. You can build a table of characters with their diacritics to their corresponding "base" character, wrap the lookup into a function and you're good to go.


Here is another answer: check this Englishizer

```function Englishizer(var strIn)
{   
 var strOut
    var strMid
    var n 
    For int (n = 1; n<strIn.Length;n++)
{
        strMid = substring(strIn, n, 1)
        Select Case strMid.charCodeAt(0)
        Case 192 To 197:
            strMid = "A"
        Case 198:
            strMid = "AE"
        Case 199:
            strMid = "C"
        Case 200 To 203:
            strMid = "E"
        Case 204 To 207:
            strMid = "I"
        Case 208:
            strMid = "D"
        Case 209:
            strMid = "N"
        Case 210 To 214, 216:
            strMid = "O"
        Case 215:
            strMid = "x"
        Case 217 To 220:
            strMid = "U"
        Case 221:
            strMid = "Y"
        Case 222, 254:
            strMid = "p"
        Case 223:
            strMid = "B"
        Case 224 To 229:
            strMid = "a"
        Case 230:
            strMid = "ae"
        Case 231:
            strMid = "c"
        Case 232 To 235:
            strMid = "e"
        Case 236 To 239:
            strMid = "i"
        Case 240, 242 To 246, 248:
            strMid = "o"
        Case 241:
            strMid = "n"
        Case 249 To 252:
            strMid = "u"
        Case 253, 255:
            strMid = "y"

        Englishizer = Englishizer + strMid;
}
}
```


Here is another answer: Here's one version of a function that does that in Ruby, that I did. Should be pretty straightforward to convert javascript.

http://snippets.dzone.com/posts/show/2384


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2009:00:03/09/09', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><unicode><character-encoding>', 'Title': 'Converting ú to u in javascript', 'ViewCount': 1842, 'id': 626792, 'user_AboutMe': '<p>Software Engineer, mainly web based experience with Scala, C# and Coffeescript.</p>\n', 'user_AccountId': 2299.0, 'user_DisplayName': 'Chris James', 'user_Reputation': 11321.0, 'user_Views': 1035.0, 'user_id': 3193.0}}