|
| 1 | +/** |
| 2 | + * Aliases assigned to a Unicode codepoint, organized by category. |
| 3 | + */ |
| 4 | +export interface UnicodeAliases { |
| 5 | + /** Correction aliases */ |
| 6 | + correction?: string[]; |
| 7 | + /** Control character aliases */ |
| 8 | + control?: string[]; |
| 9 | + /** Figment aliases */ |
| 10 | + figment?: string[]; |
| 11 | + /** Alternate name aliases */ |
| 12 | + alternate?: string[]; |
| 13 | + /** Abbreviation aliases */ |
| 14 | + abbreviation?: string[]; |
| 15 | +} |
| 16 | + |
| 17 | +/** |
| 18 | + * Returns the name that has been assigned to a Unicode codepoint. |
| 19 | + * |
| 20 | + * Please note: |
| 21 | + * Some common codepoints do not have a name (e.g. C0 control characters like \n) |
| 22 | + * |
| 23 | + * Also see: |
| 24 | + * - unicodeCorrectName(char) - Checks if there is a corrected name first, if not, |
| 25 | + * fallbacks to this method |
| 26 | + * - unicodeReadableName(char) - Displays correct name or an applicable alias |
| 27 | + * |
| 28 | + * @param char Single character string or codepoint |
| 29 | + * @returns Name of character or undefined |
| 30 | + */ |
| 31 | +export function unicodeBaseName(char: string | number): string | undefined; |
| 32 | + |
| 33 | +/** |
| 34 | + * Returns the name that has been assigned to a Unicode codepoint, but if the codepoint |
| 35 | + * has a correction alias, use this instead. |
| 36 | + * |
| 37 | + * Please note: |
| 38 | + * Some common codepoints do not have a name (e.g. C0 control characters like \n) |
| 39 | + * |
| 40 | + * Also see: |
| 41 | + * - unicodeReadableName(char) - Displays correct name or an applicable alias |
| 42 | + * |
| 43 | + * @param char Single character string or codepoint |
| 44 | + * @returns Corrected name of character or undefined |
| 45 | + */ |
| 46 | +export function unicodeCorrectName(char: string | number): string | undefined; |
| 47 | + |
| 48 | +/** |
| 49 | + * Returns the aliases that have been assigned to a Unicode codepoint. |
| 50 | + * |
| 51 | + * Aliases can be of these categories (multiple aliases possible): |
| 52 | + * |
| 53 | + * - correction |
| 54 | + * - control |
| 55 | + * - figment |
| 56 | + * - alternate |
| 57 | + * - abbreviation |
| 58 | + * |
| 59 | + * @param char Single character string or codepoint |
| 60 | + * @returns Object containing aliases for this Unicode codepoint |
| 61 | + */ |
| 62 | +export function unicodeAliases(char: string | number): UnicodeAliases | undefined; |
| 63 | + |
| 64 | +/** |
| 65 | + * Determine the basic type of codepoints. Required to be able to get the |
| 66 | + * Unicode label of a codepoint. This can be one of: |
| 67 | + * |
| 68 | + * - Graphic |
| 69 | + * - Format |
| 70 | + * - Control |
| 71 | + * - Private-use |
| 72 | + * - Surrogate |
| 73 | + * - Noncharacter |
| 74 | + * - Reserved |
| 75 | + * |
| 76 | + * @param char Single character string or codepoint |
| 77 | + * @returns Codepoint type |
| 78 | + */ |
| 79 | +export function unicodeType(char: string | number): string | undefined; |
| 80 | + |
| 81 | +/** |
| 82 | + * Returns a label of a codepoint in the following format: |
| 83 | + * <type-hex>, e.g. <control-0009> for the tab character or |
| 84 | + * <noncharacter-FFFFF> for U+FFFFF |
| 85 | + * |
| 86 | + * It is only assigned to codepoints of a type other than |
| 87 | + * "Graphic" or "Format" |
| 88 | + * |
| 89 | + * @param char Single character string or codepoint |
| 90 | + * @returns A generic label for this codepoint |
| 91 | + */ |
| 92 | +export function unicodeLabel(char: string | number): string | undefined; |
| 93 | + |
| 94 | +/** |
| 95 | + * Returns the best readable representation of a codepoint. |
| 96 | + * |
| 97 | + * 1) It is the corrected name of a the codepoint (if one exists) |
| 98 | + * 2) or it is an appropriate aliase (if one exists) |
| 99 | + * 3) or it is the codepoint label |
| 100 | + * |
| 101 | + * @param char Single character string or codepoint |
| 102 | + * @returns Unicode name, alias, or label for this character |
| 103 | + */ |
| 104 | +export function unicodeReadableName(char: string | number): string | undefined; |
| 105 | + |
| 106 | +/** |
| 107 | + * Returns the name of a character that is made of a codepoint sequence (= more than |
| 108 | + * one codepoint involved), if one exists. |
| 109 | + * |
| 110 | + * @param char Single character string made of multiple codepoints |
| 111 | + * @returns Unicode sequence name |
| 112 | + */ |
| 113 | +export function unicodeSequenceName(char: string): string | undefined; |
| 114 | + |
| 115 | +/** |
| 116 | + * Returns the name of a character that is made of a codepoint sequence (= more than |
| 117 | + * one codepoint involved), if one exists. |
| 118 | + * |
| 119 | + * Differently from unicodeSequenceName(char), it will only consider Emoji ZWJ sequences |
| 120 | + * that are fully qualified, meaning they all required variation selectors (VS16) in place |
| 121 | + * |
| 122 | + * @param char Single character string made of multiple codepoints |
| 123 | + * @returns Unicode sequence name |
| 124 | + */ |
| 125 | +export function unicodeQualifiedSequenceName(char: string): string | undefined; |
| 126 | + |
| 127 | +/** |
| 128 | + * Returns the best name for the Unicode character (codepoint or codepoint sequence). |
| 129 | + * |
| 130 | + * At first, it will check if the codepoint sequence has a name, e.g. for |
| 131 | + * Emoji that are build up using multiple codepoints using unicodeSequenceName(char) |
| 132 | + * |
| 133 | + * If none is found, will use the unicodeReadableName(char) function to retrieve |
| 134 | + * the best name for that codepoint. |
| 135 | + * |
| 136 | + * @param char Single character string or codepoint |
| 137 | + * @returns Name of character |
| 138 | + */ |
| 139 | +export function unicodeName(char: string | number): string | undefined; |
0 commit comments