Remove accents/diacritics in a string in JavaScript

前端 未结 29 2534
轻奢々
轻奢々 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:58

    normalize-diacritics is very useful

        const { normalize } = require('normalize-diacritics');
         
        /** Assuming top-level await is enabled... */
        await normalize('söme stüff with áccènts'); // 'some stuff with accents'
    

提交回复
热议问题