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?
Yes, all the parameters you access via $_GET and $_POST are decoded.
PHP | urlencode() Function. The urlencode() function is an inbuilt function in PHP which is used to encode the url. This function returns a string which consist all non-alphanumeric characters except -_. and replace by the percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs.
URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when embedded in a block of text to be transmitted in a URL the characters < and > are encoded as %3c and %3e.
application/x-www-form-urlencoded type This is a type of encoding-decoding approach where the built-in PHP functions urlencode() and urldecode()are implemented to encode and decode the URL, respectively. This encoding will replace almost all the special characters other than (_), (-), and (.) in the given URL.
Your string is also UTF-8 encoded. This will work:
echo utf8_decode(urldecode("Ant%C3%B4nio+Carlos+Jobim"));
Output: "Antônio Carlos Jobim".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With