Skip to content
Advertisement

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

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement