I have the following output from strace and i want to convert it to UTF-8 using PHP:
R\00f6dhakev\00e4gen 4
R\00e4ntm\00e4starv\00e4gen 24
K\00d8BENHAVN
The above strings is UTF 16 HEX i think.
I have the following output from strace and i want to convert it to UTF-8 using PHP:
R\00f6dhakev\00e4gen 4
R\00e4ntm\00e4starv\00e4gen 24
K\00d8BENHAVN
The above strings is UTF 16 HEX i think.
Try this:
function masked_utf16_to_utf8($str) {
$str = preg_replace_callback('/\\\\([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/', create_function('$match', 'return mb_convert_encoding(chr(hexdec("$match[1]")).chr(hexdec("$match[2]")), "UTF-8", "UTF-16");');
return $str;
}