unicode to ascii (v8)

Revision 8 of this benchmark created by ju1ius on


Description

Testing various methods of converting Unicode characters to ASCII

Preparation HTML

<script>
  var uniStrings = new Array("René Magritt", "András Süto", "Nicómede", "ééééé", "john", "charles", "cow"),
      strReplace, stripaccents, stripRange,
      strReplaceLazy, stripRangeLazy, stripaccentsJoin;

// String replace
(function(scope){
 // remove accents, swap ñ for n, etc
 var from = "àáäâèéëêìíïîòóöôùúüûñç",
     to = "aaaaeeeeiiiioooouuuunc";
strReplace = function(str) {
 var i, l;
 for (i = 0, l = from.length; i < l; i++) {
   str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
 }
 return str;
}

}(this));


// lokup table

(function(scope){
// String containing replacement characters for stripping accents 
var stripstring = 'AAAAAAACEEEEIIII' + 'DNOOOOO.OUUUUY..' + 'aaaaaaaceeeeiiii' + 'dnooooo.ouuuuy.y' + 'AaAaAaCcCcCcCcDd' + 'DdEeEeEeEeEeGgGg' + 'GgGgHhHhIiIiIiIi' + 'IiIiJjKkkLlLlLlL' + 'lJlNnNnNnnNnOoOo' + 'OoOoRrRrRrSsSsSs' + 'SsTtTtTtUuUuUuUu' + 'UuUuWwYyYZzZzZz.';

stripaccents = function(str) {
 var answer = '';
 for (var i = 0; i < str.length; i++) {
  var ch = str[i];
  var chindex = ch.charCodeAt(0) - 192; // Index of character code in the strip string
  if (chindex >= 0 && chindex < stripstring.length) {
   // Character is within our table, so we can strip the accent...
   var outch = stripstring.charAt(chindex);
   // ...unless it was shown as a '.'
   if (outch != '.') ch = outch;
  }
  answer += ch;
 }
 return answer;
}

}(this));


//unicode ranges

(function(scope){

 var repChar = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'];
 var rExps = [/[\xC0-\xC2]/g, /[\xE0-\xE2]/g, /[\xC8-\xCA]/g, /[\xE8-\xEB]/g, /[\xCC-\xCE]/g, /[\xEC-\xEE]/g, /[\xD2-\xD4]/g, /[\xF2-\xF4]/g, /[\xD9-\xDB]/g, /[\xF9-\xFB]/g],
     rlen = rExps.length;

stripRange = function(str) {
  for (var i = 0; i < rlen; i++) {
    str = str.replace(rExps[i], repChar[i]);
  }
  return str;
}

}(this));


//String replace lazy init

(function(scope){
function createRegex() {
 var regArray = new Array();
 var from = "àáäâèéëêìíïîòóöôùúüûñç";
 for (var i = 0; i < from.length; i++) {
  regArray[i] = new RegExp(from.charAt(i), 'g');
 }
 return regArray;
}
var regArray = createRegex(), reglen = regArray.length;
strReplaceLazy = function(str) {
 // remove accents, swap ñ for n, etc
 var to = "aaaaeeeeiiiioooouuuunc";
 for (var i = 0; i < reglen; i++) {
  str = str.replace(regArray[i], to.charAt(i));
 }
 return str;
}

}(this));

//unicode ranges  with lazy init
(function(scope){
var rExps = [/[\xC0-\xC2]/g, /[\xE0-\xE2]/g, /[\xC8-\xCA]/g, /[\xE8-\xEB]/g, /[\xCC-\xCE]/g, /[\xEC-\xEE]/g, /[\xD2-\xD4]/g, /[\xF2-\xF4]/g, /[\xD9-\xDB]/g, /[\xF9-\xFB]/g],
    repChar = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'],
    rlen = rExps.length;

stripRangeLazy = function(str) {
  for (var i = 0; i < rlen; i++){
     str = str.replace(rExps[i], repChar[i]);
  }
  return str;
}
}(this));

//lookup table join
(function(){
// String containing replacement characters for stripping accents 
var stripstring = 'AAAAAAACEEEEIIII' + 'DNOOOOO.OUUUUY..' + 'aaaaaaaceeeeiiii' + 'dnooooo.ouuuuy.y' + 'AaAaAaCcCcCcCcDd' + 'DdEeEeEeEeEeGgGg' + 'GgGgHhHhIiIiIiIi' + 'IiIiJjKkkLlLlLlL' + 'lJlNnNnNnnNnOoOo' + 'OoOoRrRrRrSsSsSs' + 'SsTtTtTtUuUuUuUu' + 'UuUuWwYyYZzZzZz.',
    striplen = stripstring.length;

stripaccentsJoin = function(str) {
 var answer = [];
 for (var i = 0, l = str.length; i < l; i++) {
  var ch = str[i];
  var chindex = ch.charCodeAt(0) - 192; // Index of character code in the strip string
  if (chindex >= 0 && chindex < striplen) {
   // Character is within our table, so we can strip the accent...
   var outch = stripstring.charAt(chindex);
   // ...unless it was shown as a '.'
   if (outch != '.') {
    ch = outch;
   }
  }
  answer[i] = ch;
 }
 return answer.join("");
}
}(this));

// String.prototype.unaccent
(function(){

var charmap = {
  "\u00c1": "A",
  "\u0102": "A",
  "\u1eae": "A",
  "\u1eb6": "A",
  "\u1eb0": "A",
  "\u1eb2": "A",
  "\u1eb4": "A",
  "\u01cd": "A",
  "\u00c2": "A",
  "\u1ea4": "A",
  "\u1eac": "A",
  "\u1ea6": "A",
  "\u1ea8": "A",
  "\u1eaa": "A",
  "\u00c4": "A",
  "\u01de": "A",
  "\u0226": "A",
  "\u01e0": "A",
  "\u1ea0": "A",
  "\u0200": "A",
  "\u00c0": "A",
  "\u1ea2": "A",
  "\u0202": "A",
  "\u0100": "A",
  "\u0104": "A",
  "\u00c5": "A",
  "\u01fa": "A",
  "\u1e00": "A",
  "\u023a": "A",
  "\u00c3": "A",
  "\ua732": "AA",
  "\u00c6": "AE",
  "\u01fc": "AE",
  "\u01e2": "AE",
  "\ua734": "AO",
  "\ua736": "AU",
  "\ua738": "AV",
  "\ua73a": "AV",
  "\ua73c": "AY",
  "\u1e02": "B",
  "\u1e04": "B",
  "\u0181": "B",
  "\u1e06": "B",
  "\u0243": "B",
  "\u0182": "B",
  "\u0106": "C",
  "\u010c": "C",
  "\u00c7": "C",
  "\u1e08": "C",
  "\u0108": "C",
  "\u010a": "C",
  "\u0187": "C",
  "\u023b": "C",
  "\u010e": "D",
  "\u1e10": "D",
  "\u1e12": "D",
  "\u1e0a": "D",
  "\u1e0c": "D",
  "\u018a": "D",
  "\u1e0e": "D",
  "\u01f2": "D",
  "\u01c5": "D",
  "\u0110": "D",
  "\u018b": "D",
  "\u01f1": "DZ",
  "\u01c4": "DZ",
  "\u00c9": "E",
  "\u0114": "E",
  "\u011a": "E",
  "\u0228": "E",
  "\u1e1c": "E",
  "\u00ca": "E",
  "\u1ebe": "E",
  "\u1ec6": "E",
  "\u1ec0": "E",
  "\u1ec2": "E",
  "\u1ec4": "E",
  "\u1e18": "E",
  "\u00cb": "E",
  "\u0116": "E",
  "\u1eb8": "E",
  "\u0204": "E",
  "\u00c8": "E",
  "\u1eba": "E",
  "\u0206": "E",
  "\u0112": "E",
  "\u1e16": "E",
  "\u1e14": "E",
  "\u0118": "E",
  "\u0246": "E",
  "\u1ebc": "E",
  "\u1e1a": "E",
  "\ua76a": "ET",
  "\u1e1e": "F",
  "\u0191": "F",
  "\u01f4": "G",
  "\u011e": "G",
  "\u01e6": "G",
  "\u0122": "G",
  "\u011c": "G",
  "\u0120": "G",
  "\u0193": "G",
  "\u1e20": "G",
  "\u01e4": "G",
  "\u1e2a": "H",
  "\u021e": "H",
  "\u1e28": "H",
  "\u0124": "H",
  "\u2c67": "H",
  "\u1e26": "H",
  "\u1e22": "H",
  "\u1e24": "H",
  "\u0126": "H",
  "\u00cd": "I",
  "\u012c": "I",
  "\u01cf": "I",
  "\u00ce": "I",
  "\u00cf": "I",
  "\u1e2e": "I",
  "\u0130": "I",
  "\u1eca": "I",
  "\u0208": "I",
  "\u00cc": "I",
  "\u1ec8": "I",
  "\u020a": "I",
  "\u012a": "I",
  "\u012e": "I",
  "\u0197": "I",
  "\u0128": "I",
  "\u1e2c": "I",
  "\ua779": "D",
  "\ua77b": "F",
  "\ua77d": "G",
  "\ua782": "R",
  "\ua784": "S",
  "\ua786": "T",
  "\ua76c": "IS",
  "\u0134": "J",
  "\u0248": "J",
  "\u1e30": "K",
  "\u01e8": "K",
  "\u0136": "K",
  "\u2c69": "K",
  "\ua742": "K",
  "\u1e32": "K",
  "\u0198": "K",
  "\u1e34": "K",
  "\ua740": "K",
  "\ua744": "K",
  "\u0139": "L",
  "\u023d": "L",
  "\u013d": "L",
  "\u013b": "L",
  "\u1e3c": "L",
  "\u1e36": "L",
  "\u1e38": "L",
  "\u2c60": "L",
  "\ua748": "L",
  "\u1e3a": "L",
  "\u013f": "L",
  "\u2c62": "L",
  "\u01c8": "L",
  "\u0141": "L",
  "\u01c7": "LJ",
  "\u1e3e": "M",
  "\u1e40": "M",
  "\u1e42": "M",
  "\u2c6e": "M",
  "\u0143": "N",
  "\u0147": "N",
  "\u0145": "N",
  "\u1e4a": "N",
  "\u1e44": "N",
  "\u1e46": "N",
  "\u01f8": "N",
  "\u019d": "N",
  "\u1e48": "N",
  "\u0220": "N",
  "\u01cb": "N",
  "\u00d1": "N",
  "\u01ca": "NJ",
  "\u00d3": "O",
  "\u014e": "O",
  "\u01d1": "O",
  "\u00d4": "O",
  "\u1ed0": "O",
  "\u1ed8": "O",
  "\u1ed2": "O",
  "\u1ed4": "O",
  "\u1ed6": "O",
  "\u00d6": "O",
  "\u022a": "O",
  "\u022e": "O",
  "\u0230": "O",
  "\u1ecc": "O",
  "\u0150": "O",
  "\u020c": "O",
  "\u00d2": "O",
  "\u1ece": "O",
  "\u01a0": "O",
  "\u1eda": "O",
  "\u1ee2": "O",
  "\u1edc": "O",
  "\u1ede": "O",
  "\u1ee0": "O",
  "\u020e": "O",
  "\ua74a": "O",
  "\ua74c": "O",
  "\u014c": "O",
  "\u1e52": "O",
  "\u1e50": "O",
  "\u019f": "O",
  "\u01ea": "O",
  "\u01ec": "O",
  "\u00d8": "O",
  "\u01fe": "O",
  "\u00d5": "O",
  "\u1e4c": "O",
  "\u1e4e": "O",
  "\u022c": "O",
  "\u01a2": "OI",
  "\ua74e": "OO",
  "\u0190": "E",
  "\u0186": "O",
  "\u0222": "OU",
  "\u1e54": "P",
  "\u1e56": "P",
  "\ua752": "P",
  "\u01a4": "P",
  "\ua754": "P",
  "\u2c63": "P",
  "\ua750": "P",
  "\ua758": "Q",
  "\ua756": "Q",
  "\u0154": "R",
  "\u0158": "R",
  "\u0156": "R",
  "\u1e58": "R",
  "\u1e5a": "R",
  "\u1e5c": "R",
  "\u0210": "R",
  "\u0212": "R",
  "\u1e5e": "R",
  "\u024c": "R",
  "\u2c64": "R",
  "\ua73e": "C",
  "\u018e": "E",
  "\u015a": "S",
  "\u1e64": "S",
  "\u0160": "S",
  "\u1e66": "S",
  "\u015e": "S",
  "\u015c": "S",
  "\u0218": "S",
  "\u1e60": "S",
  "\u1e62": "S",
  "\u1e68": "S",
  "\u1e9e": "SS",
  "\u0164": "T",
  "\u0162": "T",
  "\u1e70": "T",
  "\u021a": "T",
  "\u023e": "T",
  "\u1e6a": "T",
  "\u1e6c": "T",
  "\u01ac": "T",
  "\u1e6e": "T",
  "\u01ae": "T",
  "\u0166": "T",
  "\u2c6f": "A",
  "\ua780": "L",
  "\u019c": "M",
  "\u0245": "V",
  "\ua728": "TZ",
  "\u00da": "U",
  "\u016c": "U",
  "\u01d3": "U",
  "\u00db": "U",
  "\u1e76": "U",
  "\u00dc": "U",
  "\u01d7": "U",
  "\u01d9": "U",
  "\u01db": "U",
  "\u01d5": "U",
  "\u1e72": "U",
  "\u1ee4": "U",
  "\u0170": "U",
  "\u0214": "U",
  "\u00d9": "U",
  "\u1ee6": "U",
  "\u01af": "U",
  "\u1ee8": "U",
  "\u1ef0": "U",
  "\u1eea": "U",
  "\u1eec": "U",
  "\u1eee": "U",
  "\u0216": "U",
  "\u016a": "U",
  "\u1e7a": "U",
  "\u0172": "U",
  "\u016e": "U",
  "\u0168": "U",
  "\u1e78": "U",
  "\u1e74": "U",
  "\ua75e": "V",
  "\u1e7e": "V",
  "\u01b2": "V",
  "\u1e7c": "V",
  "\ua760": "VY",
  "\u1e82": "W",
  "\u0174": "W",
  "\u1e84": "W",
  "\u1e86": "W",
  "\u1e88": "W",
  "\u1e80": "W",
  "\u2c72": "W",
  "\u1e8c": "X",
  "\u1e8a": "X",
  "\u00dd": "Y",
  "\u0176": "Y",
  "\u0178": "Y",
  "\u1e8e": "Y",
  "\u1ef4": "Y",
  "\u1ef2": "Y",
  "\u01b3": "Y",
  "\u1ef6": "Y",
  "\u1efe": "Y",
  "\u0232": "Y",
  "\u024e": "Y",
  "\u1ef8": "Y",
  "\u0179": "Z",
  "\u017d": "Z",
  "\u1e90": "Z",
  "\u2c6b": "Z",
  "\u017b": "Z",
  "\u1e92": "Z",
  "\u0224": "Z",
  "\u1e94": "Z",
  "\u01b5": "Z",
  "\u0132": "IJ",
  "\u0152": "OE",
  "\u1d00": "A",
  "\u1d01": "AE",
  "\u0299": "B",
  "\u1d03": "B",
  "\u1d04": "C",
  "\u1d05": "D",
  "\u1d07": "E",
  "\ua730": "F",
  "\u0262": "G",
  "\u029b": "G",
  "\u029c": "H",
  "\u026a": "I",
  "\u0281": "R",
  "\u1d0a": "J",
  "\u1d0b": "K",
  "\u029f": "L",
  "\u1d0c": "L",
  "\u1d0d": "M",
  "\u0274": "N",
  "\u1d0f": "O",
  "\u0276": "OE",
  "\u1d10": "O",
  "\u1d15": "OU",
  "\u1d18": "P",
  "\u0280": "R",
  "\u1d0e": "N",
  "\u1d19": "R",
  "\ua731": "S",
  "\u1d1b": "T",
  "\u2c7b": "E",
  "\u1d1a": "R",
  "\u1d1c": "U",
  "\u1d20": "V",
  "\u1d21": "W",
  "\u028f": "Y",
  "\u1d22": "Z",
  "\u00e1": "a",
  "\u0103": "a",
  "\u1eaf": "a",
  "\u1eb7": "a",
  "\u1eb1": "a",
  "\u1eb3": "a",
  "\u1eb5": "a",
  "\u01ce": "a",
  "\u00e2": "a",
  "\u1ea5": "a",
  "\u1ead": "a",
  "\u1ea7": "a",
  "\u1ea9": "a",
  "\u1eab": "a",
  "\u00e4": "a",
  "\u01df": "a",
  "\u0227": "a",
  "\u01e1": "a",
  "\u1ea1": "a",
  "\u0201": "a",
  "\u00e0": "a",
  "\u1ea3": "a",
  "\u0203": "a",
  "\u0101": "a",
  "\u0105": "a",
  "\u1d8f": "a",
  "\u1e9a": "a",
  "\u00e5": "a",
  "\u01fb": "a",
  "\u1e01": "a",
  "\u2c65": "a",
  "\u00e3": "a",
  "\ua733": "aa",
  "\u00e6": "ae",
  "\u01fd": "ae",
  "\u01e3": "ae",
  "\ua735": "ao",
  "\ua737": "au",
  "\ua739": "av",
  "\ua73b": "av",
  "\ua73d": "ay",
  "\u1e03": "b",
  "\u1e05": "b",
  "\u0253": "b",
  "\u1e07": "b",
  "\u1d6c": "b",
  "\u1d80": "b",
  "\u0180": "b",
  "\u0183": "b",
  "\u0275": "o",
  "\u0107": "c",
  "\u010d": "c",
  "\u00e7": "c",
  "\u1e09": "c",
  "\u0109": "c",
  "\u0255": "c",
  "\u010b": "c",
  "\u0188": "c",
  "\u023c": "c",
  "\u010f": "d",
  "\u1e11": "d",
  "\u1e13": "d",
  "\u0221": "d",
  "\u1e0b": "d",
  "\u1e0d": "d",
  "\u0257": "d",
  "\u1d91": "d",
  "\u1e0f": "d",
  "\u1d6d": "d",
  "\u1d81": "d",
  "\u0111": "d",
  "\u0256": "d",
  "\u018c": "d",
  "\u0131": "i",
  "\u0237": "j",
  "\u025f": "j",
  "\u0284": "j",
  "\u01f3": "dz",
  "\u01c6": "dz",
  "\u00e9": "e",
  "\u0115": "e",
  "\u011b": "e",
  "\u0229": "e",
  "\u1e1d": "e",
  "\u00ea": "e",
  "\u1ebf": "e",
  "\u1ec7": "e",
  "\u1ec1": "e",
  "\u1ec3": "e",
  "\u1ec5": "e",
  "\u1e19": "e",
  "\u00eb": "e",
  "\u0117": "e",
  "\u1eb9": "e",
  "\u0205": "e",
  "\u00e8": "e",
  "\u1ebb": "e",
  "\u0207": "e",
  "\u0113": "e",
  "\u1e17": "e",
  "\u1e15": "e",
  "\u2c78": "e",
  "\u0119": "e",
  "\u1d92": "e",
  "\u0247": "e",
  "\u1ebd": "e",
  "\u1e1b": "e",
  "\ua76b": "et",
  "\u1e1f": "f",
  "\u0192": "f",
  "\u1d6e": "f",
  "\u1d82": "f",
  "\u01f5": "g",
  "\u011f": "g",
  "\u01e7": "g",
  "\u0123": "g",
  "\u011d": "g",
  "\u0121": "g",
  "\u0260": "g",
  "\u1e21": "g",
  "\u1d83": "g",
  "\u01e5": "g",
  "\u1e2b": "h",
  "\u021f": "h",
  "\u1e29": "h",
  "\u0125": "h",
  "\u2c68": "h",
  "\u1e27": "h",
  "\u1e23": "h",
  "\u1e25": "h",
  "\u0266": "h",
  "\u1e96": "h",
  "\u0127": "h",
  "\u0195": "hv",
  "\u00ed": "i",
  "\u012d": "i",
  "\u01d0": "i",
  "\u00ee": "i",
  "\u00ef": "i",
  "\u1e2f": "i",
  "\u1ecb": "i",
  "\u0209": "i",
  "\u00ec": "i",
  "\u1ec9": "i",
  "\u020b": "i",
  "\u012b": "i",
  "\u012f": "i",
  "\u1d96": "i",
  "\u0268": "i",
  "\u0129": "i",
  "\u1e2d": "i",
  "\ua77a": "d",
  "\ua77c": "f",
  "\u1d79": "g",
  "\ua783": "r",
  "\ua785": "s",
  "\ua787": "t",
  "\ua76d": "is",
  "\u01f0": "j",
  "\u0135": "j",
  "\u029d": "j",
  "\u0249": "j",
  "\u1e31": "k",
  "\u01e9": "k",
  "\u0137": "k",
  "\u2c6a": "k",
  "\ua743": "k",
  "\u1e33": "k",
  "\u0199": "k",
  "\u1e35": "k",
  "\u1d84": "k",
  "\ua741": "k",
  "\ua745": "k",
  "\u013a": "l",
  "\u019a": "l",
  "\u026c": "l",
  "\u013e": "l",
  "\u013c": "l",
  "\u1e3d": "l",
  "\u0234": "l",
  "\u1e37": "l",
  "\u1e39": "l",
  "\u2c61": "l",
  "\ua749": "l",
  "\u1e3b": "l",
  "\u0140": "l",
  "\u026b": "l",
  "\u1d85": "l",
  "\u026d": "l",
  "\u0142": "l",
  "\u01c9": "lj",
  "\u017f": "s",
  "\u1e9c": "s",
  "\u1e9b": "s",
  "\u1e9d": "s",
  "\u1e3f": "m",
  "\u1e41": "m",
  "\u1e43": "m",
  "\u0271": "m",
  "\u1d6f": "m",
  "\u1d86": "m",
  "\u0144": "n",
  "\u0148": "n",
  "\u0146": "n",
  "\u1e4b": "n",
  "\u0235": "n",
  "\u1e45": "n",
  "\u1e47": "n",
  "\u01f9": "n",
  "\u0272": "n",
  "\u1e49": "n",
  "\u019e": "n",
  "\u1d70": "n",
  "\u1d87": "n",
  "\u0273": "n",
  "\u00f1": "n",
  "\u01cc": "nj",
  "\u00f3": "o",
  "\u014f": "o",
  "\u01d2": "o",
  "\u00f4": "o",
  "\u1ed1": "o",
  "\u1ed9": "o",
  "\u1ed3": "o",
  "\u1ed5": "o",
  "\u1ed7": "o",
  "\u00f6": "o",
  "\u022b": "o",
  "\u022f": "o",
  "\u0231": "o",
  "\u1ecd": "o",
  "\u0151": "o",
  "\u020d": "o",
  "\u00f2": "o",
  "\u1ecf": "o",
  "\u01a1": "o",
  "\u1edb": "o",
  "\u1ee3": "o",
  "\u1edd": "o",
  "\u1edf": "o",
  "\u1ee1": "o",
  "\u020f": "o",
  "\ua74b": "o",
  "\ua74d": "o",
  "\u2c7a": "o",
  "\u014d": "o",
  "\u1e53": "o",
  "\u1e51": "o",
  "\u01eb": "o",
  "\u01ed": "o",
  "\u00f8": "o",
  "\u01ff": "o",
  "\u00f5": "o",
  "\u1e4d": "o",
  "\u1e4f": "o",
  "\u022d": "o",
  "\u01a3": "oi",
  "\ua74f": "oo",
  "\u025b": "e",
  "\u1d93": "e",
  "\u0254": "o",
  "\u1d97": "o",
  "\u0223": "ou",
  "\u1e55": "p",
  "\u1e57": "p",
  "\ua753": "p",
  "\u01a5": "p",
  "\u1d71": "p",
  "\u1d88": "p",
  "\ua755": "p",
  "\u1d7d": "p",
  "\ua751": "p",
  "\ua759": "q",
  "\u02a0": "q",
  "\u024b": "q",
  "\ua757": "q",
  "\u0155": "r",
  "\u0159": "r",
  "\u0157": "r",
  "\u1e59": "r",
  "\u1e5b": "r",
  "\u1e5d": "r",
  "\u0211": "r",
  "\u027e": "r",
  "\u1d73": "r",
  "\u0213": "r",
  "\u1e5f": "r",
  "\u027c": "r",
  "\u1d72": "r",
  "\u1d89": "r",
  "\u024d": "r",
  "\u027d": "r",
  "\u2184": "c",
  "\ua73f": "c",
  "\u0258": "e",
  "\u027f": "r",
  "\u015b": "s",
  "\u1e65": "s",
  "\u0161": "s",
  "\u1e67": "s",
  "\u015f": "s",
  "\u015d": "s",
  "\u0219": "s",
  "\u1e61": "s",
  "\u1e63": "s",
  "\u1e69": "s",
  "\u0282": "s",
  "\u1d74": "s",
  "\u1d8a": "s",
  "\u023f": "s",
  "\u0261": "g",
  "\u00df": "ss",
  "\u1d11": "o",
  "\u1d13": "o",
  "\u1d1d": "u",
  "\u0165": "t",
  "\u0163": "t",
  "\u1e71": "t",
  "\u021b": "t",
  "\u0236": "t",
  "\u1e97": "t",
  "\u2c66": "t",
  "\u1e6b": "t",
  "\u1e6d": "t",
  "\u01ad": "t",
  "\u1e6f": "t",
  "\u1d75": "t",
  "\u01ab": "t",
  "\u0288": "t",
  "\u0167": "t",
  "\u1d7a": "th",
  "\u0250": "a",
  "\u1d02": "ae",
  "\u01dd": "e",
  "\u1d77": "g",
  "\u0265": "h",
  "\u02ae": "h",
  "\u02af": "h",
  "\u1d09": "i",
  "\u029e": "k",
  "\ua781": "l",
  "\u026f": "m",
  "\u0270": "m",
  "\u1d14": "oe",
  "\u0279": "r",
  "\u027b": "r",
  "\u027a": "r",
  "\u2c79": "r",
  "\u0287": "t",
  "\u028c": "v",
  "\u028d": "w",
  "\u028e": "y",
  "\ua729": "tz",
  "\u00fa": "u",
  "\u016d": "u",
  "\u01d4": "u",
  "\u00fb": "u",
  "\u1e77": "u",
  "\u00fc": "u",
  "\u01d8": "u",
  "\u01da": "u",
  "\u01dc": "u",
  "\u01d6": "u",
  "\u1e73": "u",
  "\u1ee5": "u",
  "\u0171": "u",
  "\u0215": "u",
  "\u00f9": "u",
  "\u1ee7": "u",
  "\u01b0": "u",
  "\u1ee9": "u",
  "\u1ef1": "u",
  "\u1eeb": "u",
  "\u1eed": "u",
  "\u1eef": "u",
  "\u0217": "u",
  "\u016b": "u",
  "\u1e7b": "u",
  "\u0173": "u",
  "\u1d99": "u",
  "\u016f": "u",
  "\u0169": "u",
  "\u1e79": "u",
  "\u1e75": "u",
  "\u1d6b": "ue",
  "\ua778": "um",
  "\u2c74": "v",
  "\ua75f": "v",
  "\u1e7f": "v",
  "\u028b": "v",
  "\u1d8c": "v",
  "\u2c71": "v",
  "\u1e7d": "v",
  "\ua761": "vy",
  "\u1e83": "w",
  "\u0175": "w",
  "\u1e85": "w",
  "\u1e87": "w",
  "\u1e89": "w",
  "\u1e81": "w",
  "\u2c73": "w",
  "\u1e98": "w",
  "\u1e8d": "x",
  "\u1e8b": "x",
  "\u1d8d": "x",
  "\u00fd": "y",
  "\u0177": "y",
  "\u00ff": "y",
  "\u1e8f": "y",
  "\u1ef5": "y",
  "\u1ef3": "y",
  "\u01b4": "y",
  "\u1ef7": "y",
  "\u1eff": "y",
  "\u0233": "y",
  "\u1e99": "y",
  "\u024f": "y",
  "\u1ef9": "y",
  "\u017a": "z",
  "\u017e": "z",
  "\u1e91": "z",
  "\u0291": "z",
  "\u2c6c": "z",
  "\u017c": "z",
  "\u1e93": "z",
  "\u0225": "z",
  "\u1e95": "z",
  "\u1d76": "z",
  "\u1d8e": "z",
  "\u0290": "z",
  "\u01b6": "z",
  "\u0240": "z",
  "\ufb00": "ff",
  "\ufb03": "ffi",
  "\ufb04": "ffl",
  "\ufb01": "fi",
  "\ufb02": "fl",
  "\u0133": "ij",
  "\u0153": "oe",
  "\ufb06": "st",
  "\u2090": "a",
  "\u2091": "e",
  "\u1d62": "i",
  "\u2c7c": "j",
  "\u2092": "o",
  "\u1d63": "r",
  "\u1d64": "u",
  "\u1d65": "v",
  "\u2093": "x"
},
regex = /[^\x00-\xff]/g,
replacement = function(m) {
  if(charmap.hasOwnProperty(m)) return charmap[m]
  return m;
};

String.prototype.unaccent = function()
{
  return this.replace(regex, replacement);
};

}());

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
String replace
for (var c = 0, l = uniStrings.length; c < l; c++) {
  strReplace(uniStrings[c]);
}
ready
lookup table
for (var c = 0, l = uniStrings.length; c < l; c++) {
  stripaccents(uniStrings[c]);
}
ready
unicode ranges
for (var c = 0, l = uniStrings.length; c < l; c++) {
  stripRange(uniStrings[c]);
}
 
ready
String replace lazy init
for (var c = 0, l = uniStrings.length; c < l; c++) {
  strReplaceLazy(uniStrings[c]);
}
ready
unicode ranges with lazy init
for (var c = 0, l = uniStrings.length; c < l; c++) {
  stripRangeLazy(uniStrings[c]);
}
ready
lookup table join
for (var c = 0, l = uniStrings.length; c < l; c++) {
  stripaccentsJoin(uniStrings[c]);
}
 
ready
String.prototype.unaccent
for (var c = 0, l = uniStrings.length; c < l; c++) {
  uniStrings[c].unaccent();
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.