IOSOR Learn

Managing GSM-7 and Unicode Byte Limits in API Payloads

Control SMS payload encoding rules through IOSOR API integrations. Prevent hidden multi-part message segment fees by auditing character limits programmatically.

Managing GSM-7 and Unicode Byte Limits in API Payloads.

Detecting Character Encoding in API Payloads

When sending text payloads via API, the system automatically evaluates whether the string fits inside the standard GSM-7 character set or requires UCS-2 Unicode encoding. If a payload contains a single character outside the GSM-7 alphabet—such as certain emoji symbols or non-latin scripts—the entire SMS switches from 160 bits per segment down to 70 bits per segment. This automatic shift drastically alters segment counts and impacts your prepaid balance. Within the ledger, every unexpected multi-part message burns through your buffer faster than anticipated.

Technical Differences Between GSM-7 and UCS-2

The GSM-7 alphabet includes standard Latin characters, numbers, and specific Greek symbols, packed efficiently into 7-bit units. However, extended characters like brackets, curly braces, and certain symbols consume two character units despite appearing as single glyphs. When UCS-2 is triggered, every character requires 16 bits (2 bytes), cutting the maximum single-segment message length from 160 characters down to 70. Multi-part concatenation headers further reduce available payload space per segment, accelerating your cost per dispatch.

Calculating Message Segments and Multi-Part Limits

Calculating exact segment boundaries requires parsing strings byte-by-byte rather than relying solely on string length methods in your local runtime. A payload containing 161 standard GSM-7 characters splits into two segments, effectively doubling the API submission cost for that single dispatch. If the same payload triggers Unicode due to a stray smart quote or accent mark, the cost multiplies further across shorter segment thresholds. To maintain financial control, inspect string buffers before hitting the gateway.

Optimizing Templates to Prevent Unexpected Billing

Message templates for OTP, transactional alerts, and notifications should be strictly audited to remove hidden Unicode characters. Common culprits include formatted punctuation copied from rich-text editors, such as em-dashes, smart quotes, and non-breaking spaces. Replacing these with standard ASCII equivalents guarantees GSM-7 compliance and maximizes segment capacity. You can verify template rendering by sending test requests to developer numbers and monitoring the returned segment metadata.

Reconciling DLR Logs and API Ledger Data

Detailed delivery reports provide crucial visibility into how carrier gateways processed your text payloads. When discrepancies arise between expected segment counts and actual ledger deductions, engineering teams must cross-reference webhook logs with the IOSOR transaction ledger. For broader API architecture patterns and financial reconciliation processes, review API invoice week: idempotency gaps that duplicate debit, analyze API Volume Review: Idempotency at Load, and check your catalog health via Catalog second month: In setup still must not debit as Live.

Start with IOSOR

Configure pre-flight string encoding validation in your IOSOR console settings or API integration pipeline before pushing automated templates to production. Set up payload inspection gates to sanitize hidden Unicode characters and evaluate byte counts before dispatching requests to downstream gateways. Monitor your webhook DLR feeds and ledger logs to instantly catch unexpected multi-segment bursts triggered by extended character sets.

IOSOR takeaway

This analysis proves that a single non-GSM-7 character—such as a smart quote, em-dash, or emoji—instantly shifts an entire payload from standard 7-bit encoding to 16-bit UCS-2, drastically lowering segment thresholds from 160 to 70 characters. Enforcing strict byte-level parsing and encoding detection at the payload assembly stage prevents accidental multi-part message splitting across your API traffic.

Do replace smart quotes and extended symbols with standard GSM-7 equivalents in your template repositories prior to dispatch. Don't rely on simple string length functions in application code, as they fail to account for multi-byte code points and two-unit GSM extension characters.

Was this guide helpful?

Related guides