1/** 2 * When searching a table with accented characters, it can be frustrating to have 3 * an input such as _Zurich_ not match _Zürich_ in the table (`u !== ü`). This 4 * type based search plug-in replaces the built-in string formatter in 5 * DataTables with a function that will replace the accented characters 6 * with their unaccented counterparts for fast and easy filtering. 7 * 8 * Note that this plug-in uses the Javascript I18n API that was introduced in 9 * ES6. For older browser's this plug-in will have no effect. 10 * 11 * @summary Replace accented characters with unaccented counterparts 12 * @name Accent neutralise 13 * @author Allan Jardine 14 * 15 * @example 16 * $(document).ready(function() { 17 * $('#example').dataTable(); 18 * } ); 19 */ 20 21(function(){ 22 23function removeAccents ( data ) { 24 if ( data.normalize ) { 25 // Use I18n API if avaiable to split characters and accents, then remove 26 // the accents wholesale. Note that we use the original data as well as 27 // the new to allow for searching of either form. 28 return data +' '+ data 29 .normalize('NFD') 30 .replace(/[\u0300-\u036f]/g, ''); 31 } 32 33 return data; 34} 35 36var searchType = jQuery.fn.DataTable.ext.type.search; 37 38searchType.string = function ( data ) { 39 return ! data ? 40 '' : 41 typeof data === 'string' ? 42 removeAccents( data ) : 43 data; 44}; 45 46searchType.html = function ( data ) { 47 return ! data ? 48 '' : 49 typeof data === 'string' ? 50 removeAccents( data.replace( /<.*?>/g, '' ) ) : 51 data; 52}; 53 54}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.