I'm struggling to find a solution (built in or library) to the problem of decoding a URL containing percent-encoded characters outside the ASCII range.
As far as I understand RFC 3986 we shouldn't decode a URL as a whole, without first breaking it into components. However, this seems to be what browsers do with "international" characters. For example if I paste this URL into the address bar of Google Chrome:
http://www.example.com/?x=7%26z%3D6&q=%C3%A9
It is rendered as this:
http://www.example.com/?x=7%26z%3D6&q=é
So how do I do this with PHP without implementing my own url decoder? The built-in functionality (i.e urldecode) would return:
http://www.example.com/?x=7&z=6&q=é
Which is wrong (because there are now 3 query parameters) but expected (because urldecode is not designed to be used on entire urls)
I would like to be able to replicate the browser behaviour when displaying links in my application: in the href attribute I'll use the percent encoded form but in the anchor itself I'll use the "pretty" form.