3

When writing a text message, I was expecting that all (UK) standard keyboard characters would each use 1 character, but it seems that this isn't so - one exception I've found is the ¬ character, which seems to use at least 2 characters. This can be seen in the screenshot below, showing a text message (which should be 160 characters) showing that it is full after only 70 ¬ characters. I assume that the technical reason is the same as the explanations given in this twitter dev blogpost about how they count characters - but can anyone confirm this?

enter image description here

5

The reason is essentially the same, yes, in that it has to do with character encoding - the way human-readable characters are stored as machine-readable bits.

An SMS message has a size limit of 140 bytes, and the number of characters that can fit inside that limit depends on the encoding used.

The default GSM character set that covers the English alphabet as well as common symbols and punctuation marks uses 7 bits per character, thus allowing for a total of:
140 bytes × 8 bits per byte / 7 bits per character = 160 characters

When using language shift tables, this encoding can also support a number of other alphabets, but the number of characters is reduced slightly, as some of the 140 bytes are used to store information about which shift table exactly is used.

Another option is an 8-bit encoding, which can fit up to 140 characters per message (just like Twitter). Technical details on this seem to be sparse.

For any character not covered by the above two encodings, such as "¬", UCS-2 (now incorporated into UTF-16) has to be used. This encoding uses two bytes (16 bits) for each character, thus the total number of characters is only 70, as can be seen in your screenshot.

Crucially, even a single two-byte character causes the entire message to be encoded in UCS-2. You can see this for yourself by typing in 60 regular English characters, and then entering a special character not covered by the standard 7-bit character set. The character count will pop up, informing you that you've used up 61 of 70 characters. If you were to continue typing only English letters and standard punctuation marks or symbols, the character count wouldn't appear until you've entered 130 out of 160 characters.

  • 1
    Thanks - the final paragraph explains why putting in a single ¬ has caused havoc with text message lengths in the past! – ChrisW Sep 6 '14 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.