Published on 2006-11-23 19:13:26

In this case be sure to set the appropriate encoding that your page is using for example windows-1252, windows-1256 ... etc. It should solve the problem if ... encodeURIComponent() wasn' t used for escaping special characters.

And that's the second issue for Prototype which is the usage of encodeURIComponent() which replace each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character. The problem here that all escaping functions replace non-ASCII characters with Unicode ones, and in this case even if you set the unicode by default to windows-1252 for example, a special character will be replaced by its equivalent in unicode.

The solution

There is two possible solutions, first find a replacement for the escaping method, and the second solution which is more easy to implement is using PHP iconv extension :

So even if Prototype send data in Unicode you can get it again in its original encoding and continue your process. Will face this bug anybody who work with middle eastern or asian encoding, even french, german, dutch and any encoding which using non-ASCII character. If you use already UTF-8 in your application and database, you should be safe, and won't face this issue. Let me know if someone have found similar issue for other AJAX libraries.

Previous Page


Related Entries

Member of the PHP Magazine Network, Copyright (C) 2005-2008 phpmagazine.net All Rights Reserved