Skip to content
Advertisement

Decode string with x in PHP that has char encoded over 255

My problem is about string decoding.

Let’s assume a string like:

$str = "xcexbbxc6x9bxc2xacxe2x88xa7xe2x9fx91xe2x88xa8xe2x9fx87xc3xb7 xe2x82xacxc2xbdxe2x88x86xc3xb8xe2x86x94xc2xa2xe2x8cx90xc3xa6";

I want to decode it and to look like that: λƛ¬∧⟑∨⟇÷ €½∆ø↔¢⌐æ
I tried to use

utf8_encode(utf8_encode($str));

But it’s not what was expected.

In python something like that works:

_str = b"xcexbbxc6x9bxc2xacxe2x88xa7xe2x9fx91xe2x88xa8xe2x9fx87xc3xb7 xe2x82xacxc2xbdxe2x88x86xc3xb8xe2x86x94xc2xa2xe2x8cx90xc3xa6"
_str = _str.decode()
print(_str)

Advertisement

Answer

You don’t need to decode that. This is legal notation for strings in PHP.

$str = "xcexbbxc6x9bxc2xacxe2x88xa7xe2x9fx91xe2x88xa8xe2x9fx87xc3xb7 xe2x82xacxc2xbdxe2x88x86xc3xb8xe2x86x94xc2xa2xe2x8cx90xc3xa6";
echo $str;  //λƛ¬∧⟑∨⟇÷ €½∆ø↔¢⌐æ

https://3v4l.org/0e0Po

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement