MCPcopy Index your code
hub / github.com/Exafunction/codeium-chrome / numUtf8BytesToNumCodeUnits

Function numUtf8BytesToNumCodeUnits

src/utf.ts:40–55  ·  view source on GitHub ↗
(text: string, numUtf8Bytes?: number)

Source from the content-addressed store, hash-verified

38}
39
40export function numUtf8BytesToNumCodeUnits(text: string, numUtf8Bytes?: number): number {
41 if (numUtf8Bytes === 0) {
42 return 0;
43 }
44 let curNumCodeUnits = 0;
45 let curNumUtf8Bytes = 0;
46 for (const codePoint of text) {
47 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48 curNumUtf8Bytes += numUtf8BytesForCodePoint(codePoint.codePointAt(0)!);
49 curNumCodeUnits += codePoint.length;
50 if (numUtf8Bytes !== undefined && curNumUtf8Bytes >= numUtf8Bytes) {
51 break;
52 }
53 }
54 return curNumCodeUnits;
55}

Callers 2

renderCompletionMethod · 0.90

Calls 1

numUtf8BytesForCodePointFunction · 0.85

Tested by

no test coverage detected