| 7 | const decoder = new TextDecoder(); |
| 8 | |
| 9 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected