Solved

javascript encoding and php decoding

Posted on 2006-11-03
3
1,934 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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