Design & Download
Your JS Library
in Seconds!!!

Snippet: deburr() - Remove Diacritics from Characters

Written by Christopher West (cwest) on August 07, 2016.
Remove the most common diacritics from the characters in a string.
var deburr;
(function(RGX_DEBURR, ARR_DEBURR, RGX_NON_SPACE) {
  function replaceDeburrChar() {
    return ARR_DEBURR[slice(arguments, 1).join(' ').search(RGX_NON_SPACE, '')];
  }
  deburr = function(str) {
    return str.replace(RGX_DEBURR, replaceDeburrChar);
  };
})(
  /([\xc0-\xc5\u0100])|([\xe0-\xe5\u0101])|([\xc7\u0106\u010c])|([\xe7\u0107\u010d])|(\xd0\u0110)|(\xf0\u0111)|([\xc8-\xcb\u0112\u0116\u0118])|([\xe8-\xeb\u0113\u0117\u0119])|([\xcc-\xcf\u012a\u012e])|([\xec-\xef\u012b\u012f])|([\xd1\u0143])|([\xf1\u0144])|([\xd2-\xd6\xd8\u014c])|([\xf2-\xf6\xf8\u014d])|([\xd9-\xdc\u016a])|([\xf9-\xfc\u016b])|([\xdd\u0178])|([\xfd\xff])|(\xc6)|(\xe6)|(\xde)|(\xfe)|(\xdf)|(\u0152)|(\u0153)|(\u0141)|(\u0142)|([\u02B9-\u036F])/g,
  'A,a,C,c,D,d,E,e,I,i,N,n,O,o,U,u,Y,y,Ae,ae,Th,th,ss,Oe,oe,L,l,'.split(','),
  /\S/
);

deburr(...) API Documentation

Description

Converts supplementary latin letters into basic latin letters, removing the diacritical marks.

Parameters

  1. str {string}:
    The string to be modified and returned without supplementary latin letters.

Returns

Returns a copy of str but with all of the following characters replaced by their corresponding basic latin letters:
  • À, Á, Â, Ã, Ä, Å, Ā convert to A
  • à, á, â, ã, ä, å, ā convert to a
  • Ç, Ć, Č convert to C
  • ç, ć, č convert to c
  • Ð, Đ convert to D
  • ð, đ convert to d
  • È, É, Ê, Ë, Ē, Ė, Ę convert to E
  • è, é, ê, ë, ē, ė, ę convert to e
  • Ì, Í, Î, Ï, Ī, Į convert to I
  • ì, í, î, ï, ī, į convert to i
  • Ñ, Ń convert to N
  • ñ, ń convert to n
  • Ò, Ó, Ô, Õ, Ö, Ø, Ō convert to O
  • ò, ó, ô, õ, ö, ø, ō convert to o
  • Ù, Ú, Û, Ü, Ū convert to U
  • ù, ú, û, ü, ū convert to u
  • Ý, Ÿ convert to Y
  • ý, ÿ convert to y
  • Æ converts to Ae
  • æ converts to ae
  • Þ converts to Th
  • þ converts to th
  • ß converts to ss
  • Œ converts to Oe
  • œ converts to oe
  • Ł converts to L
  • ł converts to l