@ringring/gsm
Version:
A utility library for short messages and mobile communication
45 lines (44 loc) • 1.34 kB
TypeScript
/**
* Create message terminated (MT) parts to be sent to SMPPP linkers
*
* @param body message as string
* @param opts optional options (unicode: boolean)
* @returns {string[]} array of strings
*
* @example
* createParts('Hello World') // ['Hello World']
*/
export declare function createParts(body: string, opts?: {
unicode: boolean;
}): string[];
/**
* Return the character length of given content
*
*
* @see [String.length](https://mdn.io/Reference/Global_Objects/String/length)
*
* @example
* characterCount('€') // 2 (GSM 03.38, 7bit)
* characterCount('€', { unicode: true }) // 1 (UCS2, unicode)
*
* @param content message content
* @param opts.unicode boolean, if true, count as unicode instead of GSM 03.38
* @param opts.unicode boolean, if true, count as unicode instead of GSM 03.38
*/
export declare function characterCount(content: string, opts?: {
unicode: boolean;
}): number;
/**
* Replace invalid unicode characters with sane equivalence or question mark (?)
*
* @example
* // character with sane replacements
* unicodeReplace('ýô') // 'yo'
* // Invalid characters
* unicodeReplace('A你Z') // 'A??Z'
* // Valid characters
* unicodeReplace('ΘΞÆæß') // 'ΘΞÆæß'
*
* @param content message content
*/
export declare function unicodeReplace(content: string): string;