Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
strace から次の出力があり、PHP を使用して UTF-8 に変換したい:
R\00f6dhakev\00e4gen 4 R\00e4ntm\00e4starv\00e4gen 24 K\00d8BENHAVN
上記の文字列はUTF 16 HEXだと思います。
これを試して:
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; }