Solved

javascript encoding and php decoding

Posted on 2006-11-03
3
1,930 Views
Last Modified: 2009-06-08

we're using javascript to encode a form and submit it to a php script.

it works well for the most part but certain characters don't seem to be decoded by php correctly.

For example, if we use the javascript function encodeURIComponents on a right curly quote (”) it produces: %E2%80%9D

when php decodes this, we get three characters: the letter a with a circumflex, what looks like a Euro sign, and some other character (”)

is there a way we can get php to understand that these three codes are actually one right curly quote character ... or a way we can get javascript to convert it to a code that php will decode correctly.

PS - I'm not sure how the special characters I've pasted into this text box will get displayed on experts-exchange.

-Charlie
0
Comment
Question by:gothamww
3 Comments
 
LVL 15

Accepted Solution

by:
JakobA earned 500 total points
ID: 17871739
It sound like your PHP and your browser uses different character sets. the characters abowe %80 vary in different languages and character sets.

In this case it even seems like Javascript uses unicode in its encoding (16 bit characters) that lets it encode any of thousands of different characters (sigma. epsilon, arabic, katakana).

But AFAIK there is no version of PHP that support other than 8-bit character sets (not sure here, wait for other comments)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now