DataTable.util.diacritics()
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.
Types
function diacritics( str [, appendOriginal] )
- Description:
Normalise diacritic characters in a string.
- Returns:
Updated string
Example
Remove diacritics from a string:
let noAccents = DataTable.util.diacritics('Crème Brulée');
// result is: 'Creme Brulee'