News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evert Pot's Blog:
Javscript's escape and encodeURI vs. PHP $_POST
January 07, 2010 @ 14:10:46

Evert Pot came across something strange in an application he was working with - the incorrect decoding of data coming back from an Ajax call POSTed back into the app.

Basically, data is coming into our PHP application through a Javascript's XMLHttpRequest (ajax). [...] Normally everything in the $_POST and $_GET arrays is already decoded, so when you're dealing with these arrays you don't really have to think about this. This time however, I was dealing with some non-latin unicode characters and for some reason they were never decoded and ended up in the database as raw url-encoded strings.

The issue was caused by the fact that the non-latin characters were handled differently on the byte level and that, because of the choice PHP makes on which of the unicode characters to use for spaces, he found that there were two options for handling strings - escape() and encodeURI().

0 comments voice your opinion now!
javascript encode encodeuri nonlatin character


blog comments powered by Disqus

Similar Posts

Joshua Eichorn's Blog: I'll be speaking at php/works

Felix Geisendorfer's Blog: How to organize your CakePHP App's Javascript?

PHPClasses.org: Lately in PHP, Episode 27 - Running PHP code with JavaScript and Python VM

PHPBuilder.com: Using XML - A PHP Developer\'s Primer (Part 4) - XML-RPC, PHP and Javascript

Rob Allen's Blog: UTF8, PHP and MySQL


Community Events

Don't see your event here?
Let us know!


introduction extension series interview release language api laravel voicesoftheelephpant framework version podcast community opinion wordpress laravel5 unittest php7 library list

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework