AES Encryption Explained: How It Works and Why It Matters
Jun 23, 2026
Count SMS characters, split preview parts, and detect the encoding used for the current text.
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 / 7
} else if (message is 8-bit encoded) {
characters_per_part = 140 - len(UDH)
} else 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,000 characters. 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 GSM character 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 / 7
if (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.
Using this SMS character counter is quick and straightforward. Follow these steps:
A single SMS message can contain up to 160 characters using GSM 7-bit encoding, or 70 characters using Unicode (16-bit) encoding. Once you exceed these limits, the message is split into multiple parts with a User Data Header (UDH), reducing the available characters per part to 153 for 7-bit and 67 for Unicode.
GSM 7-bit uses the default GSM 03.38 alphabet with 128 characters (letters, numbers, and common symbols). It allows up to 160 characters per SMS. Unicode (UCS-2) is used when your message contains characters outside the GSM charset — such as emoji, certain accented letters, or special symbols — and reduces the limit to 70 characters per SMS.
When a message exceeds a single SMS segment, a User Data Header (UDH) of 6 bytes is added to each part. For 7-bit encoded multipart messages, each part holds 153 characters. For Unicode multipart messages, each part holds 67 characters. This tool automatically calculates these limits for you.
Your message switches to Unicode encoding when it contains one or more characters that are not part of the GSM 03.38 default alphabet. Common examples include emoji (😊), curly quotes (""), dashes (—), and accented characters like é or ü. Once Unicode is triggered, the entire message uses 16-bit encoding.
SMS parts (also called segments) are the individual messages your phone sends when the text exceeds the single-SMS limit. Most mobile carriers charge per part, not per message. For example, a 200-character message in GSM 7-bit is split into 2 parts (153 + 47), and you may be billed for 2 SMS messages. This tool helps you avoid unexpected charges by showing the exact number of parts.
Blog
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026