phpurlutf-8urldecode

URL Decoding in PHP


I am trying to decode this URL string using PHP's urldecode function:

urldecode("Ant%C3%B4nio+Carlos+Jobim");

This is supposed to output...

'Antônio Carlos Jobim'

...but instead is ouptutting this

'Antônio Carlos Jobim'

I've tested the string in a JS-based online decoder with great success, but can't seem to do this operation server side. Any ideas?


Solution

  • Your string is also UTF-8 encoded. This will work:

    echo utf8_decode(urldecode("Ant%C3%B4nio+Carlos+Jobim"));
    

    Output: "Antônio Carlos Jobim".