Skip to content

Instantly share code, notes, and snippets.

@pitakill
Created October 10, 2017 00:49
Show Gist options
  • Save pitakill/ca29aadd857dd37fabe359f2122b19a5 to your computer and use it in GitHub Desktop.
Save pitakill/ca29aadd857dd37fabe359f2122b19a5 to your computer and use it in GitHub Desktop.
normalize
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