Monday, February 6th, 2006

AJAX and Multibyte Character Support

Category: Ajax

Taylan Pince has a post on his blog that looks at an issue several don’t think about when developing pages/applications with Ajax – multibyte caharacter support.

I love AJAX, and I realize that there are more than enough tutorials on the subject floating around the web these days (my favourite is still the one over at the Apple Developer Connection). But when I wanted to use a simple AJAX menu for a site I was developing in Turkish, I quickly realized that there are some issues about character encoding in dynamically loaded AJAX elements, and that there are no apparent solutions.

He creates a solution in a few simple lines of code to make the script the Ajax connection calls use a properly formatted UTF-8 content type. The code is there to take advantage of, as well as a simple function-based usage method he suggests.

Posted by Chris Cornutt at 4:02 pm
6 Comments

+++--
3.7 rating from 23 votes

6 Comments »

Comments feed TrackBack URI

javascript’s ecape() and unecape() may help it out

Comment by beenhero — February 7, 2006

sorry ;-)
they are escape() and unescape()

Comment by beenhero — February 7, 2006

In perl the easiest is of course:

use HTML::Entities;
# and later...
print encode_entities($output);


and $output is html encoded.

Comment by Csson — February 7, 2006

Remember, escape() and friends aren’t the solution. The solution is to know your data and output it in the correct encoding. The correct encoding being UTF-8, unless you have very good reasons otherwise.

Comment by Dominic Mitchell — February 7, 2006

Dominic,
May I ask why escape isn’t an acceptable solution. I have been using this soltution a while and it even solves problems concering characters in languages such as russian and greek (non-western character set).

Best regards,
hbi

Comment by Hakan Bilgin — February 7, 2006

Hakan.. I believe escape is deprecated in the ECMA3 spec. The recommended method is encodeURIComponent(), which encodes in UTF-8.
(supported since Netscape 6/IE 5.5)

Comment by cedsav — February 7, 2006

Leave a comment

You must be logged in to post a comment.