smstwiliomessagegsmucs2

GSM encoding for SMS with special characters (Twilio)


I hope and you can help me with this query that I have.

I need to send messages with special characters avoiding to segment the message too much, that is, if the maximum number of characters for a GSM message is 160 and I write a message lower than the limit allowed for GSM with the simple fact of having at least one special character this message is change to UCS2.

I do not know if there is a way to avoid this, and that the message is only encoded with GSM without importing special characters to prevent the message from costing more.

Thank you in advance and greetings.

Example (Text):

Encoded: GSM

Message: Hola Señor Cliente le informamos que ya está disponible su crédito, acuda a las oficinas de Compañia o marque al 00110011001.

Length: 125

Segments: 1

Encoded: UCS2

Message: Hola Señor Cliente le informamos que ya está disponible su crédito, acuda a las oficinas de Compañia o marque al 00110011001.

Length: 125

Segments: 2

Example (Image):

GSM

UCS2


Solution

  • Twilio developer evangelist here.

    You cannot send special characters as a GSM encoded message because those characters do not exist within the GSM character set. This is why Twilio encodes those messages as UCS2 (well, really as UTF16 big endian). However when messages are encoded in UCS2, you can only fit 70 characters.

    The only way to ensure that your messages are not encoded as UCS2 is to avoid any characters outside of the GSM character set.

    You can read more about how Twilio handles special characters in the API in the first part of this blog post on adventures in unicode SMS.

    Let me know if that helps at all.