tty-strings
Version:
Tools for working with strings displayed in the terminal
24 lines • 1.04 kB
TypeScript
/**
* Get the visual width of a Unicode code point.
*
* @remarks
* Full width code points are include those with an `East_Asian_Width` property of `F` or `W`,
* which are derived from {@link https://unicode.org/Public/16.0.0/ucd/EastAsianWidth.txt}.
* Zero width code points include those with general category values of `Mn`, `Me`, and `Cc`,
* which are derived from {@link https://unicode.org/Public/16.0.0/ucd/extracted/DerivedGeneralCategory.txt},
* as well as all code points with the `Default_Ignorable_Code_Point` property,
* which are derived from {@link https://unicode.org/Public/16.0.0/ucd/DerivedCoreProperties.txt}.
*
* @example
* ```ts
* import { codePointWidth } from 'tty-strings';
*
* // The numerical code point for '古' is 53E4
* const width = codePointWidth(0x53E4); // 2
* ```
*
* @param code - Unicode code point.
* @returns `2` for full width, `0` for zero width, and `1` for everything else.
*/
export default function codePointWidth(code: number): 0 | 1 | 2;
//# sourceMappingURL=codePoint.d.ts.map