Mike de Vrind
Mike de Vrind

Reputation: 183

Encoding for SMS messages

I'm currently building an application which uses Nexmo to send SMS messages to users. But I'm experiencing some problems with the encoding of messages. Probably worth metioning; I'm using the prawnsalad/Nexmo-PHP-lib library to connect with their API.

A simple text messages of 160 characters is divided into 3 separate messages. According to the Nexmo support, this is caused by the encoding of the message. So to provide me with some more information I recevied the follow information about the encoding:

The maximum number of characters per message depends on the encoding: - 160 characters for 7-bit encoding (e.g. Latin-1/9 and GSM8) - 140 characters for 8-bit encoding (Binary) - 70 characters for 16-bit encoding (Unicode)

The maximum number of characters per concatenated message depends on the encoding: - 153 characters for 7-bit encoding (e.g. Latin-1/9 and GSM8) - 134 characters for 8-bit encoding (Binary) - 67 characters for 16-bit encoding (Unicode)

When I use the 7BIT encoding (mb_convert_encoding('message', '7bit')) the entire message goes out as a single text message... BUT characters like "é", "è", "à", "ù" are removed from the message. There must be a way to include this charachters and still send out the message as 1 message and not 3.. right? But how?

I really hope that someone here can help with this issue, even the support of Nexmo took a step back from this encoding issue :p

Upvotes: 2

Views: 2701

Answers (2)

GuidN
GuidN

Reputation: 108

Nexmo/Vonage supports two main types of encoding for the SMS API : text and unicode.

Unicode is limited to 70 characters, Text is 160. Nexmo PHP lib is by default set to Unicode, you have to set it to text

new SMS($sms_number, $sms_from, $sms_content, 'text') 

You can use this characters in Text without problem : "é", "è", "à", "ù".

More information in Nexmo SMS encoding documentation

Upvotes: 0

Kevin Sandow
Kevin Sandow

Reputation: 4033

Unfortunately these characters are not included in the GSM8 encoding, which is explained in great detail here: http://www.clockworksms.com/blog/the-gsm-character-set/

If you're required to use those characters there is no way around 8-bit encoding and thus fewer characters.

The same thing happens if your SMS on your mobile shows current character usage, then the character count changes drastically whenever you are using characters not included in the GSM8 encoding.

Upvotes: 2

Related Questions