Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encode french/spanish characters to use clickatell's http api?

I think some of you have experience working with Clickatell. My problem is: when I send a message through their http api using french or spanish characters (URL encode), they are not displayed (the characters) on the phone.

I'm using this -guide-: http:// support.clickatell.com /faq.php?mode=view_entry&kbid=121&kbcat=26

I already tested it with several phones and they all show the same: " a va! mon l ve mi ni a?" It should be "ça va! mon élève mi niña?" (or something pretty similar)

Unfortunately their support is not quite specific (for me), and I'm a little confused now, this is what I got:

Please see: http://www.dreamfabric.com/sms/default_alphabet.html

Thereafter, please URL Encode your text= parameter according to the above standards to have your French characters display correctly on your handset.

like image 422
Shaz Avatar asked Nov 29 '10 15:11

Shaz


2 Answers

Basically with SMS you have two options for sending text: either use the "default alphabet" that is specified in GSM 03.38 or use Unicode.

The default alphabet is the usual way to send SMS in most western countries, as it offers an acceptable subset for the languages in this region. It is a 7 bit encoding, therefore you can fit up to 160 characters into the 140 bytes available. "Up to", because this encoding uses several tables. You can access characters in extension table(s) by prefixing the character with escape(s) (0x1B). So the 7 bit encoding saves place if you are mostly using the first table.

The other option is to use Unicode (specifically UCS-2). Obviously this gives you a much broader character set but at the cost of space: using two bytes for each character this encoding leaves you with a 70 character limit.

I can't speak for Clickatell, as I never used them, but some providers offer you an abstract API that let's you use popular encodings such as ISO-8859-1 ("latin-1"). At some point this is still recoded to the 7 bit default alphabet. Even some mapping rules may be applied, e.g. use 'è' instead of 'é' because the former looks almost the same and is in the default alphabet. Of course, if you want to have full control over the content then you need to use an API that lets you transmit text encoded in the GSM default alphabet.

like image 57
paprika Avatar answered Oct 23 '22 11:10

paprika


Here's some workaround. All characters with '^' will be replaced by the regular letter:

$message = 'éàçùêâôûîï';
$message = urlencode(utf8_decode($message));

The recieved SMS will look like this:

éàcùeaouii
like image 33
Vlad Avatar answered Oct 23 '22 10:10

Vlad