* Load bytearray as string from ptr. * @param byteArrayPtr The head address of the bytearray.
(byteArrayPtr: Pointer)
| 225 | * @param byteArrayPtr The head address of the bytearray. |
| 226 | */ |
| 227 | loadByteArrayAsString(byteArrayPtr: Pointer): string { |
| 228 | if (this.buffer != this.memory.buffer) { |
| 229 | this.updateViews(); |
| 230 | } |
| 231 | const ptr = this.loadPointer(byteArrayPtr); |
| 232 | const length = this.loadUSize(byteArrayPtr + this.sizeofPtr()); |
| 233 | // NOTE: the views are still valid for read. |
| 234 | const ret = []; |
| 235 | for (let i = 0; i < length; i++) { |
| 236 | ret.push(String.fromCharCode(this.viewU8[ptr + i])); |
| 237 | } |
| 238 | return ret.join(""); |
| 239 | } |
| 240 | /** |
| 241 | * Load bytearray as bytes from ptr. |
| 242 | * @param byteArrayPtr The head address of the bytearray. |
no test coverage detected