/** * Pure, DOM-free SMS encoding + segmentation helpers. * * SMS messages are plain text, but how many "segments" (billable parts) a * message costs depends on its characters: * * - **GSM-7**: the default 7-bit alphabet. 160 chars in a single segment, 153 * per segment once the message is split (the extra 7 bits per segment go to * the multipart UDH header). A handful of characters (`^ { } \ [ ] ~ | €` and * form-feed) live in an "extension table" and cost **two** characters each. * - **UCS-2**: used when any character is outside GSM-7 (e.g. emoji, many * non-Latin scripts). 70 chars single, 67 per segment when split. Counted in * UTF-16 code units, so emoji built from surrogate pairs cost two. * * Reference: 3GPP TS 23.038. */ /** Which physical encoding the carrier will use for the message. */ export type SmsEncoding = 'GSM-7' | 'UCS-2'; /** A full segmentation report for a piece of text. */ export interface SmsSegmentInfo { /** Encoding the message forces. */ encoding: SmsEncoding; /** Weighted character count (GSM-7 extension chars count as 2). */ length: number; /** Number of billable segments. */ segments: number; /** Capacity of a single segment for the active encoding (160 or 70). */ maxSingle: number; /** Capacity per segment once the message is multipart (153 or 67). */ maxMulti: number; /** Characters left before the next segment boundary. */ remaining: number; } /** * Determine whether `text` can be sent as GSM-7 or must fall back to UCS-2. */ export declare function detectEncoding(text: string): SmsEncoding; /** * Weighted length of `text` for the given encoding. In GSM-7, extension-table * characters count as two. In UCS-2, the count is in UTF-16 code units (so a * surrogate-pair emoji counts as two). */ export declare function countChars(text: string, encoding: SmsEncoding): number; /** * Produce a full segmentation report for `text`: encoding, weighted length, * segment count, per-segment capacity and remaining characters. */ export declare function segment(text: string): SmsSegmentInfo;