Remove accents/diacritics in a string in JavaScript

前端 未结 29 2442
轻奢々
轻奢々 2020-11-21 13:29

How do I remove accentuated characters from a string? Especially in IE6, I had something like this:

accentsTidy = function(s){
    var r=s.toLowerCase();
           


        
29条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-21 13:43

    Assuming you know what you're doing, I suspect IE6 is not interpreting the file's encoding correctly, and hence not recognising the non-ASCII characters in the file:

    • Make sure the file is saved as UTF-8 (say)
    • Use Fiddler or some other tool to check that the web server is sending the correct Content-Encoding HTTP header.

    (It "smells" wrong though, I'd look into doing the sorting, say on the server using something that's locale-aware... but anyway...)

提交回复
热议问题