My picI know this is a port mania today but i finally solved a problem that has been bugging me for a few days now. I wanted to send an sms via Clicaktell’s gateway that i wanted it to be utf. This gateway supports this kind of messages but with a trick.

When you set the UTF support on your message, your message needs to be UTF-16 url encoded. This is tricky. For instance the folloring will not work.

urlencode(mb_convert_encoding($text, 'UTF-16', 'UTF-8'))

With this you will get an error message saying that your utf data are not right. Please notice that i used mb_convert_encoding from the mbstring module in php (more about the mbstring module in php’s manual here). So here is a function i found on php.net’s manual and i modified a little bit to use.

function utf16urlencode($str)
{
    $str = mb_convert_encoding($str, 'UTF-16', 'UTF-8');
    $out = '';
    for ($i = 0; $i < mb_strlen($str, 'UTF-16'); $i++)
    {
        $out .= bin2hex(mb_substr($str, $i, 1, 'UTF-16'));
    }
    return $out;
}

Using the function above you can convert your string to add it in the url of the message sending. Hope this helps!