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 this:
str_replace("x02x59","x04xd9",$string);
This didn't work. How do I go about this?
**EDIT: Additional information.
Thanks bobince, that has done the trick. Although, I want to replace the uppercase schwa also and it is not working for some reason. I calculated U+018F (?) as UTF-8 0xC68F and this is to be replaced with U+04D8 (0xD398):
$string = str_replace("xC9x99", "xD3x99", $_POST['string_with_schwa']); //lc 259->4d9
$string = str_replace( "xC68F", "xD3x98" , $string); //uc 18f->4d8
I am copying the '?' into a textbox and posting it. The first str_replace
works fine on the lowercase, but does not detect the uppercase in the second str_replace
, strange. It remains as U+018F. Guess I could run the string through strtolower
but this should work though.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…