The URL encoding of η is %CE%B7
. But in PHP I get some strange symbols when I write echo urldecode("%ce%b7");
Instead, if I write echo urlencode("η");
then I get %26%23951%3B
. Why can't I use %CE%B7
?
Solution
The Problem is that we use typo3. It some how does not use unicode for internal processing. As soon as we set $TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8';
in typo3 the output of echo urldecode("%ce%b7");
was correct.
For why echo urlencode("η");
gives me %26%23951%3B
see the answers of Joni.
urldecode("%ce%b7")
produces η encoded in UTF-8. If you are viewing the output with some other encoding you may see something else.
On the other hand, when you decode %26%23951%3B
it's true that you don't obtain η; you obtain η
which is a HTML entity code for η. To decode entity codes use html_entity_decode
:
echo html_entity_decode('η', false, 'UTF-8'); // prints η, encoded in UTF-8
You can try the following
header('Content-Type: text/html; charset=utf-8');
echo urldecode("%ce%b7"); // output : η
See Live Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With