SMS Counter

Share this:
Type or paste the SMS string here:
Encoding: 7bit  SMS parts: 0  Chars used: 0  Chars in SMS: 160
 

Encoding preview

Message content missing

Legend

  - Regular 7bit character, present in GSM charset
ESC - Escape character 0x1B; required to access |^{}[]~ extended 7bit characters
  - User Defined Header (UDH) of the message. Required for multipart sms
  - Character present in GSM charset, encoded as Unicode character
  - Character not present in GSM charset, forces to use Unicode encoding

SMS Character Count: How to Calculate According to SMS Standard (RFC)

According to the SMS standard defined in the SMS RF (GSM 03.38), a single SMS message can contain up to 160 7-bit characters, or 70 16-bit characters, or 140 8-bit characters. To count the number of characters in an SMS according to this standard, you will need to determine the character encoding of the message and then use the appropriate formula to calculate the number of characters.

For example, if the message is encoded using 7-bit characters, you can count the number of characters by dividing the number of bytes in the message by 7.

If the message is longer than the maximum allowed by a single SMS, it is possible to send it as multiple SMS messages, known as multipart SMS. In this case, the message is divided into several parts and each part is sent as a separate SMS. To concatenate the parts of the message and to keep track of the message parts, a User Data Header (UDH) is added to each SMS.

When counting the number of characters in a multipart SMS with a UDH, you will need to take into account the characters used in the UDH in addition to the characters used in the message.

The number of characters in each part of the message can be calculated as:

if (message is 7-bit encoded) characters_per_part = (140 - len(UDH)) * 8 / 7if (message is 8-bit encoded) characters_per_part = 140 - len(UDH)if (message is 16-bit encoded) characters_per_part = (140 - len(UDH)) / 2

Note: The maximum number of characters per part may vary based on the UDH length.

If the multipart SMS contains characters not present in the GSM character set and with a UDH, the process is a bit more complex.

GSM 03.38 defines a limited character set that contains only 128 characters, but Unicode contains over 110,000characters. So, when the message contains characters that are not present in the GSM character set, they need to be encoded using a technique called "character set extension" that uses two 7-bit characters to represent a single character not in the GSM character set.

To count the number of characters in a multipart SMS with a UDH that contains characters not present in the GSMcharacter set, you will need to take into account the characters used in the UDH, the number of characters not present in the GSM character set and the number of characters present in the GSM character set.

The number of characters in each part of the message can be calculated as:

if (message is 7-bit encoded) characters_per_part = (140 - len(UDH) - (number of characters not present in GSM character set)) * 8 / 7if (message is 8-bit encoded) characters_per_part = 140 - len(UDH) - (number of characters not present in GSM character set)

It's important to note that the above algorithm assumes that the message is properly encoded and the UDH is properly added to the message, also the character extension is properly applied, otherwise it may not provide an accurate count of the number of characters in the SMS.