Reputation: 73
I have a php string with the following
$string="Br\xFCtal"
Is it possible to convert the \xFC part to the correct special character?
I know this works
$string="\xFC";
echo utf8_encode($string);
but I don't know if it can be done as part of a string with other characters.
Thanks
Upvotes: 1
Views: 624
Reputation: 19764
If the encoded string is a literal encoding in JSON string, you could replace '\x' to unicode format '\u00'.
$string = '"Br\xFCtal"';
echo json_decode(str_replace('\x', '\u00', $string));
Output:
Brütal
Upvotes: 1