SMS Character and Segment Counter
Count SMS segments (GSM-7 160/153 or UCS-2 70/67), list the characters that force Unicode, get an unaccented GSM-safe version and check a brandname.
Result
Press “Run” to see the result.
An SMS holds 160 characters of the GSM 7-bit alphabet, or only 70 as soon as one character is outside it (UCS-2), and long messages are split into parts of 153 or 67 characters. Every Vietnamese accent, curly quote or emoji therefore doubles or triples the cost of a message. The API tells you the encoding, the units used (septets or UTF-16 code units, the GSM extension characters ^ { } [ ] ~ | € \ counting twice), the number of segments and what is left in the last one.
It lists each character that forces UCS-2 with its code point, position and suggested replacement, and returns a GSM-safe version of the text: Vietnamese accents removed, smart quotes, dashes and ellipses replaced, emoji dropped, with its own segment count and how many segments it saves. segments=true adds the text of each part, and brandname checks an alphanumeric sender ID (at most 11 characters).
Counting follows 3GPP TS 23.038 / 23.040; carriers may add their own limits on concatenated brandname messages.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/sms-count" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Mã OTP của bạn là 123456, hiệu lực 5 phút."}'const res = await fetch('https://apibox.io.vn/v1/sms-count', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"text": "Mã OTP của bạn là 123456, hiệu lực 5 phút."
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/sms-count",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"text": "Mã OTP của bạn là 123456, hiệu lực 5 phút."},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/sms-count');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"text":"Mã OTP của bạn là 123456, hiệu lực 5 phút."}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
Why does one accent change everything?
Vietnamese letters with accents (ă, ơ, ệ…) are not in the GSM alphabet, so the whole message switches to UCS-2: 70 characters instead of 160.
Are é, è, à allowed in GSM?
Yes, a few accented Latin letters (é è ù ì ò à Ä Ö Ñ Ü…) are part of the GSM alphabet, so they do not force UCS-2; the GSM-safe version still removes every accent, as usual for Vietnamese SMS.
How are emoji counted?
As UCS-2, and most emoji take two UTF-16 code units, so 35 emoji fill a single SMS.