MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getEmojiWidth

Function getEmojiWidth

source code/ink/stringWidth.ts:108–129  ·  view source on GitHub ↗
(grapheme: string)

Source from the content-addressed store, hash-verified

106}
107
108function getEmojiWidth(grapheme: string): number {
109 // Regional indicators: single = 1, pair = 2
110 const first = grapheme.codePointAt(0)!
111 if (first >= 0x1f1e6 && first <= 0x1f1ff) {
112 let count = 0
113 for (const _ of grapheme) count++
114 return count === 1 ? 1 : 2
115 }
116
117 // Incomplete keycap: digit/symbol + VS16 without U+20E3
118 if (grapheme.length === 2) {
119 const second = grapheme.codePointAt(1)
120 if (
121 second === 0xfe0f &&
122 ((first >= 0x30 && first <= 0x39) || first === 0x23 || first === 0x2a)
123 ) {
124 return 1
125 }
126 }
127
128 return 2
129}
130
131function isZeroWidth(codePoint: number): boolean {
132 // Fast path for common printable range

Callers 1

stringWidthJavaScriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected