(text: string)
| 2232 | } |
| 2233 | |
| 2234 | const 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 |