Replace unicode character

后端 未结 2 1753
猫巷女王i
猫巷女王i 2020-12-11 21:26

I am trying to replace a certain character in a string with another. They are quite obscure latin characters. I want to replace character (hex) 259 with 4d9, so I tried th

2条回答
  •  一向
    一向 (楼主)
    2020-12-11 22:15

    A couple of possible suggestions. Firstly, remember that you need to assign the new value to $string, i.e.:

    $string = str_replace("\x02\x59","\x04\xd9",$string);
    

    Secondly, verify that your byte stream occurs in the $string. I mention this because your hex string begins with a low-byte, so you'll need to make sure your $string is not UTF8 encoded.

提交回复
热议问题