I'm passing a pound symbol £
to a PHP page which has been URLEncoded by ASP as %C2%A3
.
The problem:
urldecode("%C2%A3") // £
ord(urldecode("%C2%A3")) // get the character number - 194
ord("£") // 163 - somethings gone wrong, they should match
This means when I do utf8_encode(urldecode("%C2%A3"))
I get £
However doing utf8_encode("£")
I get £
as expected
How can I solve this?
if you try
var_dump(urldecode("%C2%A3"));
you'll see
string(2) "£"
because this is 2-byte character and ord() returns value of first one (194 = Â)
I don't think ord()
is multibyte compatible. It's probably returning only the code for the first character in the string, which is Â. Try to utf8_decode()
the string before calling ord()
on it and see if that helps.
ord(utf8_decode(urldecode("%C2%A3"))); // This returns 163
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