function UTF8ToUTF16BE($str, $setbom = true) { $outstr = ""; if ($setbom) { $outstr .= "þÿ"; // Byte Order Mark (BOM) } $outstr .= mb_convert_encoding($str, 'UTF-16BE', 'UTF-8'); return $outstr; }