I need to convert %F3%BE%AE%A2 to this char “” in PHP. When I tried using
rawurldecode('%F3%BE%AE%A2');
then it gives 2 chars instead of 1 char.
How can I convert it properly?
EDIT:
To be more specific it’s an UTF-16 surrogate char.it gives \udbba\udfa2 in javascript.Now
if i want to send data via javascript API then i could easily send “” as a single character.
But for security reasons i need to use PHP.That’s where the problem starts.Decoding '%F3%BE%AE%A2' with rawurldecode() along with utf-8 header doesn’t seem to be giving me the char i want.
Wish i have explained it.Thanks for your appreciations.
Actually
rawurldecode()is giving you the correct result. That character consists of four bytes when encoded in utf-8 and the rule in url encoding is to convert each byte to %XX notation. rawurldecode() is giving you back those 4 bytes but probably you have not set your page’s encoding to utf-8 so your browser is misinterpreting those bytes. add this to your<head>:and you should see the right character.
This is a test page I made:
what I see in my browser:
exactly the character you want to see.