SMS

What is GSM-7 vs UCS-2 encoding?

GSM-7 fits more text per segment using a limited alphabet; UCS-2 supports more characters but leaves less room per segment.

A curly apostrophe can change the price of a text containing otherwise ordinary Latin letters. The phone displays almost the same sentence. Bird needs more network segments to send it.

What are the two encodings?

GSM-7 uses a compact alphabet, while UCS-2 represents characters outside that alphabet.

Ordinary Latin letters, digits, common punctuation and some accented letters fit GSM-7. The SMS alphabet specification defines that set.

UCS-2 carries characters outside that set, including curly quotes and emoji. Some emoji count double toward its character limit.

Chinese, Japanese, Korean, Cyrillic, Arabic, Thai and Hindi text require characters outside Bird's GSM-7 alphabet.

How does Bird choose the encoding?

Bird tests the whole body against GSM-7 and uses UCS-2 if any character fails that test.

The encoding applies to the entire body. A curly apostrophe does not receive a separate encoding from the words around it. Its presence changes the encoding of those words too.

You can check the result through segments.encoding, whose values are GSM_7BIT and UCS2.

How does encoding change the segment count?

The wider encoding leaves less room for text in each billable segment.

Bird uses these limits:

EncodingSingle segmentEach part when split
GSM-7160 characters153 characters
UCS-270 characters67 characters

These limits count certain characters double, as listed below. Each split part reserves header space so the phone can join the parts. Concatenated SMS explains the header.

A body of 155 ordinary Latin letters occupies one GSM-7 segment. Add a curly apostrophe and the 156-character body switches to UCS-2. It exceeds 70, so the multipart limit applies: 156 divided by 67 rounds up to three segments.

Bird bills each segment separately. SMS segments explains how the count becomes the billable quantity.

Which characters need special care?

Curly punctuation, emoji and letters outside the GSM-7 alphabet can change the entire message's encoding.

  • Straight apostrophes fit GSM-7; curly apostrophes do not.
  • A plain hyphen fits; typographic en dashes and em dashes do not.
  • Three periods fit; the single ellipsis character does not.
  • é and ü fit; á, í and ú do not.

GSM-7 counts these characters double: ^, {, }, \, [, ], ~, | and . Form feed, a control character requesting a page break, also counts double. Eighty euro signs therefore fill one segment.

In UCS-2, an emoji such as 😀 counts double. Thirty-five fill one segment. Adding another exceeds its capacity.1

Can smart encoding avoid the switch?

Smart encoding can replace supported punctuation when every resulting character fits GSM-7.

You enable it per send with options.smart_encoding, a boolean accepting true or false, with false as the default. A curly apostrophe can become a straight apostrophe. An ellipsis can become three periods.

Bird leaves the original body unchanged if any unsupported character remains. Arabic or Japanese text therefore retains the Unicode capacity limits. Changing the setting cannot make those scripts fit GSM-7.

Smart encoding describes the replacement rules, and the segment calculator checks text before sending.

Footnotes

  1. For custom calculators, Bird measures GSM-7 in septets and UCS2 in UTF-16 code units. GSM-7 extension characters use two septets. UTF-16 uses two code units for characters outside Unicode’s first block, including 😀.

In short

  1. The body determines the encoding.

    Bird uses GSM-7 when every character fits its alphabet and UCS-2 when any character falls outside it.

  2. Some characters count double.

    Plain Latin text fits 160 characters per segment. The wider alphabet fits 70, with some emoji counting double.

  3. Splitting reduces every part's capacity.

    Multipart messages reserve header space. Plain Latin text then fits 153 characters per part. The wider alphabet fits 67, counting some characters double.

  4. Smart encoding requires an explicit choice.

    Bird replaces supported characters only when you enable the option and the entire result fits GSM-7.

Build on the same network.

A test API key is yours immediately. Production unlocks when you add a payment method and verify a sender.

Your next idea.
Ready to connect.