/** * The encoding a carrier uses to send an SMS. * * - `gsm7`: the GSM 03.38 7-bit default alphabet. Used when every character is in the basic or extension table. * - `ucs2`: UTF-16. Used as soon as any character falls outside GSM-7, which shrinks every segment. */ export type SmsTextEncoding = 'gsm7' | 'ucs2'; /** * Characters a single GSM-7 segment holds. */ export declare const SMS_GSM7_SINGLE_SEGMENT_LENGTH = 160; /** * Characters each segment of a split GSM-7 message holds. The rest of the segment is the concatenation header. */ export declare const SMS_GSM7_MULTI_SEGMENT_LENGTH = 153; /** * UTF-16 code units a single UCS-2 segment holds. */ export declare const SMS_UCS2_SINGLE_SEGMENT_LENGTH = 70; /** * UTF-16 code units each segment of a split UCS-2 message holds. */ export declare const SMS_UCS2_MULTI_SEGMENT_LENGTH = 67; /** * Length and segment details for an SMS body. */ export interface SmsTextSegmentDetails { /** * The length the carrier counts, in the encoding's units: GSM-7 septets (extension characters count as two) or UTF-16 code units. */ readonly length: number; /** * The encoding the text is sent with. */ readonly encoding: SmsTextEncoding; /** * The number of segments the text is sent as. An empty text is 0 segments. */ readonly segments: number; } /** * Returns the length, encoding and segment count of an SMS body. * * - GSM-7 when every character is in the GSM 03.38 basic or extension table, otherwise UCS-2. * - GSM-7 fits 160 characters in one segment and 153 per segment when split. Extension characters (`^{}\[~]|€`) count as two. * - UCS-2 fits 70 code units in one segment and 67 per segment when split. Characters outside the BMP (most emoji) count as two. * - A split never divides an extension character or a surrogate pair, so a segment may end one unit short. * * @param text - The SMS body. * @returns The length, encoding and segment count. * * @dbxUtil * @dbxUtilCategory string * @dbxUtilTags sms, text, segment, gsm7, ucs2, length, encoding, twilio * * @example * ```ts * smsTextSegmentDetails('Hello!'); * // { length: 6, encoding: 'gsm7', segments: 1 } * * smsTextSegmentDetails('Hello 👋'); * // { length: 8, encoding: 'ucs2', segments: 1 } * ``` */ export declare function smsTextSegmentDetails(text: string): SmsTextSegmentDetails;