Jump to content

Encodeuricomponent Function Replacing “ And ” With “ And â€�


Greywacke

Recommended Posts

a short little test actually revealed that the following javascript code is what actually created this issue.

(%E2%80%9C%20and%20%E2%80%9D)
was alerted by opening the following javascript protocol
alert(encodeURIComponent("(“ and ”)"));
as a url in firefox.which other functions can encode a string containing double quotes without replacing them with multiple weird chars?this issue was posted at first under the PHP forum (http://w3schools.invisionzone.com/index.php?showtopic=30419).
Link to comment
Share on other sites

Those specific quotation marks are encoded in UTF-8 format. You can use the utf8_decode() function on the string when it's received on the server side.

Link to comment
Share on other sites

i tried that, but it replaces them with ? *sighs*unless you meant the utf8_decode as a javascript function, and not in the php AJAX handler where i implemented it...

Link to comment
Share on other sites

this issue has been resolved by adding a function in the form handler to convert the messed up characters to the originally input ones.

function rep_lrdquotes($string) {	return str_replace("â€","”",str_replace("“","“",$string));}

thanks for all the attempted help!

Link to comment
Share on other sites

which other functions can encode a string containing double quotes
The problem is that those aren't actually double quotes, they're some high-value unicode characters. Unicode is a multi-byte character set, so those characters require 3 bytes each. Those are the multiple characters you see when the 3 bytes get displayed as ASCII.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...