When the $urlGoBack variable contains a french accented character like "é" the following doesn't work properly, even tho I previously ensured it's being passed on to header like it should, using the mb_convert_encoding() function.
header("Location: " . $urlGoBack);
The URL I'm being taken to has "é" changed to %E9, which is its URL equivalent I guess.
HTML charset is iso-8859-1, whereas mb_detect_encoding($urlGoBack) returns UTF-8.
On the other hand, if I try converting it with
$urlGoBack = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $urlGoBack);
or
$urlGoBack = mb_convert_encoding($urlGoBack, "ISO-8859-1", "UTF-8");
then mb_detect_encoding($urlGoBack)
returns ASCII and "é" is gone, and the URL gets wrong. Surprisingly tho, it's exactly the same result when I try the seemingly trivial
$urlGoBack = mb_convert_encoding($urlGoBack , "UTF-8", "UTF-8");
Any suggestions? Thanks.
You need to use urlencode($urlGoBack), like this:
header("Location: " . urlencode($urlGoBack));