1. With the function decodeURIComponent in JavaScript

Decoding this
%E2%80%9C
will get the following

<script type="text/javascript">
function decode() {
	var obj = document.getElementById('dencoder');
	var encoded = obj.value;
	obj.value = decodeURIComponent(encoded.replace(/\+/g,  " "));
}
</script>

<textarea cols="80" rows="20" id="dencoder"></textarea>
<div>
<input type="button" onclick="decode()" value="Decode">
</div>

Working!

  1. PHP not working
    However, I am not able to decode it in PHP.
    Already tried...
echo ord(utf8_decode(urldecode("%E2%80%9D"))); 
echo "<br>";
echo ord(urldecode("%E2%80%9D")); 
echo "<br>";
// not getting this value
echo ord('“');

Any idea to decode %E2%80%9D in php and get this char “ ?

    Works for me, except that the char you have is not 9D, it's 9C.

    header('content-type: text/html; charset=utf-8');
    echo '<html><head><title>url encode / decode</title></head><body>';
    # This character needs the content-type charset to be utf-8
    # Otherwise those values doesn't represent 1 character but 3
    echo urldecode('%E2%80%9D');
    echo '<br/>';
    
    # This line needs the file to be saved as utf-8. As ISO-8859-1 that character is unmappable
    echo urlencode('“');
    
    echo '</body></html>';
    
      Write a Reply...