Drupal 7 url with hex code for special characters?
You can use the following snippet.

$decoded_url = rawurldecode(rawurldecode($url));


For example, for the second URL, the code returns http://example.com/drupal7/?q=node/1#overlay=?q=admin/config/content/formats.

That URL anyway is not usable as it is, as it would be wrongly parsed. For example, if on my browser I enter http://tero.local/dr72/?q=node/1#overlay=?q=admin/config/content/formats (tero.local is the local name used from my computer), what I get is the following page.



As you see, the overlay is not shown.
Differently, when I enter http://tero.local/dr72/?q=node/1#overlay=%3Fq%3Dadmin%252Fconfig%252Fcontent%252Fformats, I get the following.



In this case, the overlay is rendered.