Closed TiTi closed 13 years ago
Very true. :D It does both case and accent-folding. This code is an example for the accompanying article, not really production code. There are a lot of corners cut -- for example, it also does not support the "ae" ligature, or German "ss".
Since the article was published, YUI has added support for this natively, as well as jQuery (I think?). I recommend using those instead.
Also, please note that this technique is intended for internal representations of strings for the purposes of search, NOT for display back to the user or storage in a database. Removing accents does actually remove meaning and if you show folded strings back to users, you will probably make someone, somewhere, very upset.
Nope, jQuery does not support this natively yet. In fact this is the exact reason I'm looking for a good javascript accent map algorithm / list :p Precisely for the jQuery UI Autocomplete plugin: http://jqueryui.com/demos/autocomplete/ See accent folding demo (in the right menu). (so same purpose: search)
Then i found about this github project on this very good article (and blog) : http://www.alistapart.com/articles/accent-folding-for-auto-complete/
Anyways, thanks for the notes. I'll probably take a look at YUI implementation since I'm a huge fan of YUI and worked intensively with YUI2.
Ah, I see. They made a demo, but it's not part of the library. Well, this should do what you need:
https://github.com/yui/yui3/blob/master/src/text/js/text-data-accentfold.js
Good luck!
Example, with the second item of the accent_map array: 'Á':'a' Should be 'Á':'A', nope ?