When entering this url into the Browser: http://www.google.com/?q=ä
The sent url is actually http://www.google.com/?q=%C3%A4
I want to do the same conversion using Php - how to do that?
What I tried:
$url = 'http://www.google.com/?q=ä'; //utf8 encoded echo rawurlencode($url); //gives http%3A%2F%2Fwww.google.com%2F%3Fq%3D%C3%A4 $u = parse_url($url); echo $url['scheme'].'://'.$url['host'].$url['path'].'?'.rawurlencode($url['query']); //gives http://www.google.com/?q%3D%C3%A4 The above url ist just a simple example, I need a generic solution that also works with
http://www.example.com/ä http://www.example.com/ä?foo=ä&bar=ö http://www.example.com/Περιβάλλον?abc=Περιβάλλον The answer provided here is not generic enough: How to encode URL using php like browsers do