Created
August 22, 2014 21:33
-
-
Save ngryman/b8487fb71e8376709acd to your computer and use it in GitHub Desktop.
Strip diatrics from a string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var withoutDiatrics = function() { | |
var diatrics = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
var stripped = 'AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz'; | |
return function(str) { | |
var len = str.length, out = ''; | |
for (var i = 0; i < len; i++) { | |
var index = diatrics.indexOf(str[i]); | |
out += (-1 != index ? stripped[index] : str[i]); | |
} | |
return out; | |
}; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment