Solved

javascript encoding and php decoding

Posted on 2006-11-03
3
1,929 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Best database setup for image uploads 6 38
PHP string issue 5 16
Codiing Non-Existent Links 4 21
Filter wordpress query 3 5
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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 count occurrences of each item in an array.

772 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

10 Experts available now in Live!

Get 1:1 Help Now