list.js icon indicating copy to clipboard operation
list.js copied to clipboard

Support for UTF-8 special characters

Open ardziej opened this issue 13 years ago • 5 comments

Hi,is it possible to support polish characters in searching or filtering ? http://webdesign.about.com/od/localization/l/blhtmlcodes-pl.htm Strings with special characters are not properly working.

ardziej avatar Dec 03 '13 15:12 ardziej

Hmm.. could you make a JSFiddle/JSpen/JSbin that shows this problem? What happens?

javve avatar Dec 08 '13 19:12 javve

Thanks. Look at this: http://jsfiddle.net/36GHg/3/ This is generally problem of JavaScript. How is that possible that JS doesn't support UTF-8 at all ?

ardziej avatar Dec 08 '13 20:12 ardziej

There might be a fix for that. In the list.js file line 1105 (in the current master version), replace

return naturalSort(a.values()[valueName], b.values()[valueName], options);

By

return naturalSort(encodeURIComponent(a.values()[valueName]), encodeURIComponent(b.values()[valueName]), options);

I had the same issue with A and À now the À is first and the A is second, I know you want Ą to be second but I was also sure that À should have been afer A, turned out (after checking in dictionnary (France)) that words beginning by À are listed before words beginning by A.

Hope it helps you

seb-vial avatar Jan 13 '14 11:01 seb-vial

I don't think this will work better. Some characters, depending of browser, will be translated into %XX, and the '%' character will be before any alphabetic character. This as nothing to do with locale sort.

In French (and in France, I'm french), 'À' and 'A', and 'Â' also, and any accentuated character is sorted exactly as if it does not have an accent; and 'Œ' is between 'O' and 'P'. If I take a random page, I have 'accepter', then 'accès', then 'accessible'.

Sorting is dependant of locale, not every language sort characters the same way; and according to http://stackoverflow.com/questions/6909126/javascript-sort-with-unicode; the "less wrong way" is to sort using String.localeCompare(); which will work using the locale configured in the user browser. This will not be right in any case; but better than nothing.

koocotte avatar Jan 13 '14 13:01 koocotte

I'll close this with a reference to this issue: #385

javve avatar Feb 26 '16 21:02 javve