Created
October 10, 2017 00:49
-
-
Save pitakill/ca29aadd857dd37fabe359f2122b19a5 to your computer and use it in GitHub Desktop.
normalize
This file contains 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 normalize = (function() { | |
var from = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛãàáäâèéëêìíïîòóöôùúüûÑñÇç", | |
to = "AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc", | |
mapping = {}; | |
for(var i = 0, j = from.length; i < j; i++ ) | |
mapping[ from.charAt( i ) ] = to.charAt( i ); | |
return function( str ) { | |
var ret = []; | |
for( var i = 0, j = str.length; i < j; i++ ) { | |
var c = str.charAt( i ); | |
if( mapping.hasOwnProperty( str.charAt( i ) ) ) | |
ret.push( mapping[ c ] ); | |
else | |
ret.push( c ); | |
} | |
return ret.join( '' ); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment