An SMS carries 140 bytes of payload, and the encoding decides how many characters fit in them. GSM-7 packs each character into 7 bits for 160 characters, while UCS-2 uses 16 bits for 70. Your API request is plain UTF-8 JSON, so the choice between them happens after you hit send, and the only way to control it is to control the characters in your body.

This post is for the developer who wants to understand why that is, not just memorize 160 and 70. If you want a function that counts segments, we wrote that separately in SMS segment counter in code. Here we look at the encodings themselves and the decisions they push onto your product.

Where the 160 and the 70 come from

The limit is a byte budget. A single SMS has room for 140 bytes of user data, which is 1,120 bits. Divide by 7 bits per GSM-7 character and you get 160. Divide by 16 bits per UCS-2 character and you get 70. Nothing about 160 is magic. It's what 1,120 bits yields in the older, narrower alphabet.

Longer messages are sent as several linked SMS. Each part spends 6 of its 140 bytes on a header, called a user data header, that holds a reference number, the total part count and this part's position. The phone uses it to reassemble the message in order. That leaves 134 bytes, or 1,072 bits, per part. At 7 bits a character, that's 153 characters. At 16 bits a character, it's 67. Those are the numbers in every segment table, and now you can derive them yourself.

EncodingBits per characterSingle messageEach part when split
GSM-77160153
UCS-2167067

What GSM-7 includes, and what it doesn't

GSM-7 is a fixed alphabet defined for mobile networks long before emoji. It has the basic Latin letters, digits and common punctuation, plus a handful of accented letters and symbols such as the pound sign, the yen sign and a few Greek capitals. It doesn't have the full set of accented letters, and it doesn't have curly quotes, long dashes or the ellipsis character.

It also has an extension table, reached by an escape character. The caret, curly braces, backslash, square brackets, tilde, pipe and euro sign live there. Each one costs two of your 7-bit slots, one for the escape and one for the character. So a 100-character body with ten curly braces uses 110 slots, which matters only near the limit but surprises people when they paste a code snippet or a template with {braces} into a message.

What forces UCS-2

Any character outside GSM-7 and its extension table forces the whole message into UCS-2. Not that character alone, the whole message. The encoding is chosen once per message, and it applies to every part when the message is long.

The usual suspects, roughly in order of how often they sneak in:

  • Smart quotes and apostrophes from word processors and rich-text editors.
  • Long dashes and the single ellipsis character.
  • Emoji, including the ones inside a customer's name or a store title.
  • Accented letters missing from GSM-7, common in Spanish, French, Portuguese and Vietnamese names.
  • Non-Latin scripts such as Cyrillic, Arabic, Chinese, Japanese and Korean, where UCS-2 is simply the right encoding.
  • The non-breaking space and other invisible characters that arrive in pasted text.

On the last one, invisible characters are the cruelest because nobody can see them. A message that looks identical to a 160-character one can be two or three segments.

UCS-2, UTF-16 and the emoji question

Strictly, UCS-2 is a fixed-width 16-bit encoding that covers the Basic Multilingual Plane. Emoji mostly live outside it. Handsets deal with this by treating the payload as UTF-16, where a character beyond the plane is stored as a surrogate pair, two 16-bit units. The practical effect is that one emoji uses two of your 70 slots, and a family or flag emoji built from several code points can use many more.

For a developer, this means the length you care about is UTF-16 code units, not characters as a user sees them and not UTF-8 bytes. A body that's 69 user-visible characters with one emoji is 71 units. That's two segments.

Decisions to make in your product

Once you know the mechanics, there are three reasonable policies for text that your customers type.

  1. Allow it and show the cost. The simplest and most honest. Count segments in the composer and let the customer decide whether the emoji is worth tripling the cost of the send.
  2. Normalize the harmless characters. Swap curly quotes, long dashes and ellipses for plain ones before sending. Ready does this for you, so on Ready those never change the count, and your own preview should match it.
  3. Transliterate or warn on the rest. Offer to replace an accented name with its plain form, or flag the message so the customer knows it will be sent as UCS-2.

Policy 3 needs a careful hand. Rewriting a customer's name or a non-Latin message to fit GSM-7 can change meaning or offend, and for languages written in non-Latin scripts there's no good substitute. For those senders, UCS-2 is the correct cost of doing business, and the useful thing you can do is make the cost visible.

What it costs, in a worked example

Segments are what's billed, so encoding is a cost decision. Ready's Standard rate is $0.0075 per segment plus a $0.0045 carrier fee per segment, passed through at cost, or $0.012 all-in. That figure doesn't include screening, the per-segment charge for Scrub lists and Number validation when an account switches them on.

Ready's all-in prices per segment include the carrier fee but not screening: Scrub lists and Number validation, the two switches in Settings under Compliance, each add $0.003 per segment when switched on, shown as screening on your bill, and both are off by default. Unless you turn the opt-out footer off, the first text to each contact, and one again from time to time, also gets "Reply STOP to opt out" and your business name if the message does not already have them, so a text close to the segment limit can bill one more segment.

Assume a 120-character appointment reminder. In GSM-7 it's one segment. Add a single emoji and it's 121 UCS-2 units, which is 2 segments (121 divided by 67 rounds up to 2). Sent to 10,000 contacts, that's 10,000 segments versus 20,000 segments, billed at $0.012 each. The emoji doubled the bill for that send. The inputs are assumptions, but the multiplication is the same for any message.

Also remember the footer. Unless the account turns it off, Ready adds "Reply STOP to opt out" and the business name to the first text to each contact, and again from time to time. Those characters count toward the limit, so a message right at the edge of 160 can spill into a second segment when it's the contact's first text.

Storing and passing text without corrupting it

Encoding bugs also show up outside the counter. A few habits keep them away:

  • Keep the body as UTF-8 end to end in your own stack, in your database, queues and logs, and let the encoding conversion happen at the edge.
  • Don't truncate by byte length. Cutting a UTF-8 string in the middle of a character or a surrogate pair produces garbage. Truncate by code point at least, and by user-visible character if you can.
  • Log the encoding decision and the segment count next to each message, so a billing question is answerable from your own data.
  • Send with an idempotency key. A retried request shouldn't text someone twice, whatever the encoding.

The request itself doesn't change with the encoding. You send the body, and the encoding is derived from it:

POST https://api.tryready.com/v1/messages
X-API-Key: <key>
Idempotency-Key: <uuid>

{"to": "+12125550199", "body": "Your order #1042 has shipped.", "consent_attested": true}

Retries and idempotency are worth a read before you wire this into a queue, and the messages API reference lists every field.

The practical takeaway

GSM-7 is a 7-bit alphabet with an escape table, and UCS-2 is a 16-bit fallback that any outside character triggers for the whole message. The segment limits fall out of the 140-byte payload and a 6-byte concatenation header. Measure length in UTF-16 units when UCS-2 applies, normalize the harmless characters, and show customers the cost of the rest. For the marketer-facing version of the same rules, see characters per segment and the emoji tax.