()
| 234 | } |
| 235 | |
| 236 | stringWithHeader() { |
| 237 | const header = this.readVarUint36Small(); |
| 238 | const type = header & 0b11; |
| 239 | const len = header >>> 2; |
| 240 | switch (type) { |
| 241 | case LATIN1: |
| 242 | return len === 0 ? "" : this.stringLatin1(len); |
| 243 | case UTF8: |
| 244 | return len === 0 ? "" : this.stringUtf8(len); |
| 245 | case UTF16: |
| 246 | return len === 0 ? "" : this.stringUtf16LE(len); |
| 247 | default: |
| 248 | throw new Error(`Unsupported string encoding: ${type}`); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | stringLatin1(len: number) { |
| 253 | if (len < 0 || len > this.byteLength - this.cursor) { |
no test coverage detected