I'm trying to encode a feed's URLs, which unfortunately contain Unicode characters. My feed reader doesn't support this.
My knowledge in php is limited and my basic approach failed when it encountered a French character ç. Clearly listing each character is slow and too much work:
public function encodeUmlauts($req_url) {
$req_url = str_replace("ö", urlencode("ö"), $req_url);
$req_url = str_replace("ü", urlencode("ü"), $req_url);
$req_url = str_replace("ä", urlencode("ä"), $req_url);
$req_url = str_replace("Ö", urlencode("Ö"), $req_url);
$req_url = str_replace("Ü", urlencode("Ü"), $req_url);
$req_url = str_replace("Ä", urlencode("Ä"), $req_url);
$req_url = str_replace("ß", urlencode("ß"), $req_url);
return $req_url;
}
I assume something can be done with urlencode and/or parse_url, but I don't see an obvious solution.
What I'm looking for is similar to this stackoverflow question, but for PHP.
print urlencode("garçon");will outputgar%C3%A7on