Convert non-ASCII characters (umlauts, accents...) to their closest ASCII equivalent (slug creation)

The easiest way I've found:

var str = "Rånades på Skyttis i Ö-vik";
var combining = /[\u0300-\u036F]/g; 

console.log(str.normalize('NFKD').replace(combining, ''));

For reference see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize


It's because iconv is a native compiled UNIX utility behind the most i18n character map conversion functions.

You won't find it in javascript unless you access some browser component.

Encoding is a property of the document so most javascript implementation just simply dismiss it.

You'll need a pure js library for unaccented strings. It would be the best to have one for the specific language you need.

The simpliest way is via some translate tables or even regex replaces.

like here : http://lehelk.com/2011/05/06/script-to-remove-diacritics/

check this thread too : Replacing diacritics in Javascript