Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current version of drupal.js's autocomplete feature doesn't handle unicode(somebody can probably give a better explanation). All I know is that freetagging's autocomplete feature does not support Korean and I presume other unicode languages.
As thox (#drupal) suggested, I changed the escape() to encodeURIComponent() in drupal.js and now autocomplete works now. I'm submitting a patch for review as thox asked.
Comment | File | Size | Author |
---|---|---|---|
drupal.js_4.patch | 459 bytes | John Hwang | |
Comments
Comment #1
Thox CreditAttribution: Thox commentedIt may also be worthwhile to wrap encodeURIComponent() around the
i
variable on the same line.The patch should also fix accented characters, which is essentially the same problem with the escape() function. Can a JS/unicode wizard give an opinion?
Comment #2
Steven CreditAttribution: Steven commentedWhat browser are you using? Arbitrary Unicode characters work fine for me in both Safari and Firefox.
Comment #3
John Hwang CreditAttribution: John Hwang commentedWithout the encodeURIComponent(), it doesn't work for Korean (presumming Chinese and Japanese as well). Even with the new function swap, it still doesn't work in IE. Korean Freetagging autosearch does work in Firefox.
Comment #4
Steven CreditAttribution: Steven commentedThis patch only affects HTTPPost, and autocomplete only uses HTTPGet so it's logical that it doesn't fix it ;).
But, testing shows that escape() is indeed the wrong function to use. It uses %NN for unicode characters < 255 and %uNNNN with utf-16 words. encodeURIComponent() on the other hand uses %NN-escaped UTF-8 bytes. So HTTPPost needs to be changed anyway.
The issue with autocomplete is that IE doesn't deal properly with non-ASCII characters in XMLHttpRequest URIs. They get converted to "\xNN". So we need to escape the autocomplete query with encodeURIComponent() as well.
I tested this on IE6, Firefox, Opera and Safari and now arbitrary unicode works everywhere.
Comment #5
John Hwang CreditAttribution: John Hwang commentedI'm sorry, but I don't understand what you've changed... It appears as if drupal_4.js.patch is identical to the original drupal.js distributed with Beta 3. It actually reverts my patch back to the original, from encodeURIComponent() to escape()...
Comment #6
Steven CreditAttribution: Steven commentedYour patch was created in reverse. But I did more than that. See:
http://drupal.org/cvs?commit=24444
Comment #7
(not verified) CreditAttribution: commented