MCPcopy Create free account
hub / github.com/FxEmbed/FxEmbed / UnicodeString

Class UnicodeString

packages/atmosphere/src/helpers/unicode-string.ts:9–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7const decoder = new TextDecoder();
8
9export class UnicodeString {
10 utf16: string;
11 utf8: Uint8Array;
12
13 constructor(utf16: string) {
14 this.utf16 = utf16;
15 this.utf8 = encoder.encode(utf16);
16 }
17
18 get length() {
19 return this.utf8.byteLength;
20 }
21
22 slice(start?: number, end?: number): string {
23 return decoder.decode(this.utf8.slice(start, end));
24 }
25
26 utf16IndexToUtf8Index(i: number) {
27 return encoder.encode(this.utf16.slice(0, i)).byteLength;
28 }
29
30 toString() {
31 return this.utf16;
32 }
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected