Skip to content
Wire2AirWire2Air

Character encoding and message length

Which characters fit the GSM 03.38 alphabet, when a message switches to Unicode, how long messages are split into parts, and how to URL-encode text.

Last updated

Send all text as UTF-8. Wire2Air then delivers each message in one of two encodings:

  • GSM 03.38 (the GSM 7-bit default alphabet), when every character in the message is in it.
  • Unicode (UCS-2), as soon as one character is not. The whole message switches, not just that character.

The encoding decides how many characters fit in one message, and so how many credits a message uses.

GSM 03.38 alphabet

GSM 03.38 covers the Latin alphabet, digits, common punctuation, some accented letters and a few Greek capitals. The basic table has 128 positions; each character counts as one:

0x000x100x200x300x400x500x600x70
0x0@Δspace0¡P¿p
0x1£_!1AQaq
0x2$Φ"2BRbr
0x3¥Γ#3CScs
0x4èΛ¤4DTdt
0x5éΩ%5EUeu
0x6ùΠ&6FVfv
0x7ìΨ'7GWgw
0x8òΣ(8HXhx
0x9ÇΘ)9IYiy
0xAline feedΞ*:JZjz
0xBØescape+;KÄkä
0xCøÆ,<LÖlö
0xDcarriage returnæ-=MÑmñ
0xEÅß.>NÜnü
0xFåÉ/?O§oà

Extended characters

Ten more characters are sent as the escape code (0x1B) followed by a second code, so each counts as two:

CharacterCodes (hex)Codes (decimal)
€1B 6527, 101
form feed1B 0A27, 10
[1B 3C27, 60
\1B 2F27, 47
]1B 3E27, 62
^1B 1427, 20
{1B 2827, 40
|1B 4027, 64
}1B 2927, 41
~1B 3D27, 61

A line break written as \r\n (carriage return + line feed) is two basic characters, so it counts as two.

Unicode

If a message contains any character outside the two tables above (for example Chinese, Arabic or Japanese text, emoji, or typographic quotes), the whole message is sent as Unicode. Unicode allows any language, but fits fewer characters in each message.

Not every handset or carrier displays every Unicode character.

Message length

One SMS holds 160 GSM characters or 70 Unicode characters. A longer message is split into parts that the phone joins back together (a concatenated message). Each part loses room to a 7-character header (the User Data Header) that tells the phone how to join them, so a part holds 153 GSM characters or 67 Unicode characters.

PartsGSM 03.38, total charactersUnicode, total characters
116070
2306134
3459201
4612268
5765335
6918402

Up to six parts can form one long message. Each part is billed as one message.

Keep messages in GSM

A single typographic character switches a message to Unicode and cuts it from 160 to 70 characters. Text pasted from a word processor is the usual cause. Replace:

Instead ofUse
‘ ’ (curly apostrophes) and `'
“ ” (curly quotes)"
– — (dashes) and ¬-
…...

~, | and the other extended characters stay in GSM but count as two each.

The dashboard's Unicode Detect tool replaces common Unicode characters with GSM equivalents.

URL encoding

Parameters must be URL-encoded (percent-encoded): reserved characters such as &, /, ? and spaces, and every non-ASCII character, become % codes. Without encoding, an & in your text ends the parameter early.

Before and after encoding
text=A sample text & Message
text=A%20sample%20text%20%26%20Message

Every HTTP library does this for you. Pass parameters as a map or dictionary rather than building the string by hand:

  • Python 3: urllib.parse.urlencode()
  • Node: URLSearchParams
  • PHP: http_build_query() (or urlencode() for a single value)
  • C#: FormUrlEncodedContent, or Uri.EscapeDataString() for a single value
  • cURL: --data-urlencode

Encode each value once. Encoding a value and then handing it to a library that encodes again sends %2520 instead of a space.