MCPcopy Index your code
hub / github.com/codeaashu/claude-code / isZeroWidth

Function isZeroWidth

src/ink/stringWidth.ts:129–203  ·  view source on GitHub ↗
(codePoint: number)

Source from the content-addressed store, hash-verified

127}
128
129function isZeroWidth(codePoint: number): boolean {
130 // Fast path for common printable range
131 if (codePoint >= 0x20 && codePoint < 0x7f) return false
132 if (codePoint >= 0xa0 && codePoint < 0x0300) return codePoint === 0x00ad
133
134 // Control characters
135 if (codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f)) return true
136
137 // Zero-width and invisible characters
138 if (
139 (codePoint >= 0x200b && codePoint <= 0x200d) || // ZW space/joiner
140 codePoint === 0xfeff || // BOM
141 (codePoint >= 0x2060 && codePoint <= 0x2064) // Word joiner etc.
142 ) {
143 return true
144 }
145
146 // Variation selectors
147 if (
148 (codePoint >= 0xfe00 && codePoint <= 0xfe0f) ||
149 (codePoint >= 0xe0100 && codePoint <= 0xe01ef)
150 ) {
151 return true
152 }
153
154 // Combining diacritical marks
155 if (
156 (codePoint >= 0x0300 && codePoint <= 0x036f) ||
157 (codePoint >= 0x1ab0 && codePoint <= 0x1aff) ||
158 (codePoint >= 0x1dc0 && codePoint <= 0x1dff) ||
159 (codePoint >= 0x20d0 && codePoint <= 0x20ff) ||
160 (codePoint >= 0xfe20 && codePoint <= 0xfe2f)
161 ) {
162 return true
163 }
164
165 // Indic script combining marks (covers Devanagari through Malayalam)
166 if (codePoint >= 0x0900 && codePoint <= 0x0d4f) {
167 // Signs and vowel marks at start of each script block
168 const offset = codePoint & 0x7f
169 if (offset <= 0x03) return true // Signs at block start
170 if (offset >= 0x3a && offset <= 0x4f) return true // Vowel signs, virama
171 if (offset >= 0x51 && offset <= 0x57) return true // Stress signs
172 if (offset >= 0x62 && offset <= 0x63) return true // Vowel signs
173 }
174
175 // Thai/Lao combining marks
176 // Note: U+0E32 (SARA AA), U+0E33 (SARA AM), U+0EB2, U+0EB3 are spacing vowels (width 1), not combining marks
177 if (
178 codePoint === 0x0e31 || // Thai MAI HAN-AKAT
179 (codePoint >= 0x0e34 && codePoint <= 0x0e3a) || // Thai vowel signs (skip U+0E32, U+0E33)
180 (codePoint >= 0x0e47 && codePoint <= 0x0e4e) || // Thai vowel signs and marks
181 codePoint === 0x0eb1 || // Lao MAI KAN
182 (codePoint >= 0x0eb4 && codePoint <= 0x0ebc) || // Lao vowel signs (skip U+0EB2, U+0EB3)
183 (codePoint >= 0x0ec8 && codePoint <= 0x0ecd) // Lao tone marks
184 ) {
185 return true
186 }

Callers 1

stringWidthJavaScriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected