Hello;
I need this convert to use in my web sms service , couse the company which I am deailing with I have to vivst there web to make the convert to the string the copy it to my web page then send it...
so What I want to make my own convertor.
so I tried this :
<?
function utf8toucs2hex($utf8)
{
$utf8_hex = bin2hex( $utf8 );
return utf8toucs2($utf8_hex);
}
function utf8hextoucs2hex($str)
{
$ucs2 = "";
for ($i=0;$i<strlen($str);$i+=2)
{
$char1hex = $str[$i].$str[$i+1];
$char1dec = hexdec($char1hex);
if ( $char1dec < 128)
{
$results = $char1hex;
}
else if ( $char1dec < 224 )
{
$char2hex = $str[$i+2].$str[$i+3];
$results = dechex( ((hexdec($char1hex)-192)*64) + (hexdec($char2hex)-128) );
$i+=2;
}
else if ( $char1dec < 240 )
{
$char2hex = $str[$i+2].$str[$i+3];
$char3hex = $str[$i+4].$str[$i+5];
$results = dechex( ((hexdec($char1hex)-224)*4096) + ((hexdec($char2hex)-128)*64) + (hexdec($char3hex)-128) );
$i+=4;
}
else
{
//Not supported: UCS-2 only
$i+=6;
}
while ( strlen($results) < 4 )
{
$results = '0' . $results;
}
$ucs2 .= $results;
}
return $ucs2;
}
$error="";
if (isset ($_POST['submit']) && !empty($_POST['Mobile'])&& !empty($_POST['msg'])) {
$user = "username";
$password = "password";
$api_id ="apID";
$baseurl ="http://api.clickatell.com";
$text =$_POST['msg'];
$message_unicodehex = utf8toucs2hex($text);
$to = $_POST['Mobile'];
// auth call
$url = "$baseurl/http/auth?user=$user&password=$password&api_id=$api_id&unicode=1";
// do auth call
$ret = file($url);
$from="QN";
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$message_unicodehex&from=$from";
// do sendmsg call
$ret = file($url);
$send = split(":",$ret[0]);
if ($send[0] == "ID")
$error="success
message ID: ". $send[1];
else
$error='send message failed <br>check the mobile number format to be without + and without 00 ( 9746026267)';
} else {
$error="Authentication failure: ". $ret[0];
exit();
}
}
else $error="Plz Fill All the fields";
?>
So when I try the string in english it return to me the same string when I use there convertor. it works the same as there convertor , but if I put an arabic string my convertor gives defferent one then there convertor result...
what can I do?
regards..