MCPcopy Create free account
hub / github.com/Effect-TS/effect / utf8Length

Function utf8Length

packages/effect/src/ui/MessageLog.ts:2234–2246  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

2232}
2233
2234const utf8Length = (text: string): number => {
2235 let bytes = 0
2236 for (let index = 0; index < text.length; index++) {
2237 const code = text.charCodeAt(index)
2238 if (code < 0x80) bytes += 1
2239 else if (code < 0x800) bytes += 2
2240 else if (code >= 0xd800 && code < 0xdc00) {
2241 bytes += 4
2242 index++
2243 } else bytes += 3
2244 }
2245 return bytes
2246}
2247
2248/**
2249 * Makes a log that encodes entries off the runtime's path. `record` only

Callers 1

capFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected