I got data like this: "ӘІҢҒҮҰҚӨҺ". hexing this data to this: d398d086d2a2d292d2aed2b0d29ad3a8d2ba then adding "\'" for *.rtf format: \'d3\'8d\'86\'2a\'d2\'2d\'ae\'2b\'d2\'ad\'a8\'2b
and then I must get somethingl ike this: \u1179\'3f\u1240\'3f\u1186\'3f...
but str_replace replaces only slashes Q_Q.
Any suggestions?
here is full code:
<?
function strToHex($string)
{
$hex='';
for ($i=0; $i < strlen($string); $i++)
{
$hex .= dechex(ord($string[$i]));
}
return $hex;
}
function extra($txt) {
$output_arr = array (
//
"\\u1179\\'3f","\\u1240\\'3f","\\u1186\\'3f","\\u1170\\'3f","\\u1198\\'3f","\\u1200\\'3f","\\u1178\\'3f","\\u1256\\'3f","\\u1210\\'3f"
);
$input_arr = array (
//
"\\'d3\\'98","\\'d0\\'86","\\'d2\\'a2","\\'d2\\'92","\\'d2\\'ae","\\'d2\\'b0","\\'d2\\'9a","\\'d3\\'a8","\\'d2\\'ba"
);
echo "<br>";
echo "data: ".$txt."<br>";
$txt = strtohex($txt);
echo "hex: ".$txt."<br>";
for ($ii=0; $ii < strlen($txt); $ii++) {
//
if (strlen($tm1)<2) {
//
$tm1.=substr($txt,$ii,1);
}
else
{
//
$ret.="\\'".$tm1;
$tm1='';
}
}
echo "RET:[".$ret."]<br>";
$ret = str_replace($input_arr,$output_arr,$ret);
echo "RETREP:[".$ret."]<br>";
return $ret;
}
extra("ӘІҢҒҮҰҚӨҺ");
?>