MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / couldBeEmoji

Function couldBeEmoji

packages/pi-tui/src/utils.ts:27–37  ·  view source on GitHub ↗

* Check if a grapheme cluster (after segmentation) could possibly be an RGI emoji. * This is a fast heuristic to avoid the expensive rgiEmojiRegex test. * The tested Unicode blocks are deliberately broad to account for future * Unicode additions.

(segment: string)

Source from the content-addressed store, hash-verified

25 * Unicode additions.
26 */
27function couldBeEmoji(segment: string): boolean {
28 const cp = segment.codePointAt(0)!;
29 return (
30 (cp >= 0x1f000 && cp <= 0x1fbff) || // Emoji and Pictograph
31 (cp >= 0x2300 && cp <= 0x23ff) || // Misc technical
32 (cp >= 0x2600 && cp <= 0x27bf) || // Misc symbols, dingbats
33 (cp >= 0x2b50 && cp <= 0x2b55) || // Specific stars/circles
34 segment.includes("\uFE0F") || // Contains VS16 (emoji presentation selector)
35 segment.length > 2 // Multi-codepoint sequences (ZWJ, skin tones, etc.)
36 );
37}
38
39// Regexes for character classification (same as string-width library)
40const zeroWidthRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;

Callers 1

graphemeWidthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected