Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Unicode Problem with AJAX
Old 06-30-2010, 12:35 PM PHP Unicode Problem with AJAX
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Simply I have a text box and I want users to be able to use unicode characters.

When submitted, jQuery posts it to the page that handles the request and escape()'s the data.

Code:
$.post('ajax/postlike.php', { statement: escape(pstatement) }, function(data){
All is fine, but if a unicode character is submitted, then we get problems.

For example, if I submit "I’m testing this script. ♥"

It will come out as "I%u2019m testing this script. %u2665"

If I use encodeURIcomponent instead of escape, it comes out a bunch of jumble, such as the yen sign etc.

The code that parses the request goes as following:

PHP Code:
$_POST['statement'] = trim(addslashes(htmlentities(urldecode($_POST['statement'])))); 
Any suggestions?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Reply     « Reply to PHP Unicode Problem with AJAX
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07989 seconds with 12 queries