views:

375

answers:

3

how can I send sms in hebrew with clickatell ? it arrives as giberish.

+1  A: 

Is it in unicode ? If I remember correctly they require unicode to be escaped into hexadecimal representation. This should be in their docs.

However, I found out when I did this that this is not the only issue, many phones do not support displaying unicode characters properly.

Also, sending unicode may incur a higher cost since it may be split up.

PQW
A: 

Encode your message as unicode, see this FAQ page for details.

Hasturkun
A: 

Hey Guys,

Ran into the same issue... you need to encode to unicode and then convert to hex. The strange thing is that you need to take the last value and append it to the front in order to get it to work. I found this out by comparing the results of my code against the output of their online tool.

    private string ToUnicode(string val)
    {
        Encoding utf8 = Encoding.UTF8;
        Encoding unicode = Encoding.Unicode;

        byte[] utf8Bytes = utf8.GetBytes(val);

        byte[] unicodeBytes = Encoding.Convert(utf8, unicode, utf8Bytes);

        var result = ByteArrayToString(unicodeBytes);
        result = result.Substring(result.Length - 2, 2) + result.Substring(0, result.Length - 2);
        return result;
    }

    public static string ByteArrayToString(byte[] ba)
    {
        StringBuilder hex = new StringBuilder(ba.Length * 2);
        foreach (byte b in ba)
            hex.AppendFormat("{0:x2}", b);
        return hex.ToString();
    }
Ross Jones