{hero}

DataTable.util.diacritics()

Since: DataTables 2.0

Normalise diacritic characters in a string.

Description

When searching in DataTables we provide the ability to search for words which have accented characters without typing the accent. For example searching for Desiree would match Désirée.

This method exposes that ability for external use as well as the ability to replace the diacritic removal method that DataTables uses.

Our default method uses the normalize method in Javascript with a NFD normalisation form. The way this works is to decompose the accented character into a base ASCII character plus its accent as a second character. We then remove the accent characters.

If you wish to disable the diacritic normalisation that DataTables uses, you can do so by giving this method a function that simply returns the original input, e.g.:

DataTable.util.diacritics(d => d);

Using the example from before, this would mean than when searching for Desiree would not match __Désirée_.

Types

diacritics( str [, appendOriginal] )

Normalise diacritic characters in a string.

Returns:

stringUpdated string

diacritics( fn )

Set the diacritic removal function.

Example

Remove diacritics from a string:

let noAccents = DataTable.util.diacritics('Crème Brulée');

// result is: 'Creme Brulee'