| 574 | } |
| 575 | |
| 576 | textDecode (arrayBuffer: any) { |
| 577 | let decodedString: string = "" |
| 578 | if ('TextDecoder' in window) { |
| 579 | // Decode as UTF-8 |
| 580 | var dataView = new DataView(arrayBuffer) |
| 581 | var decoder = new TextDecoder('utf8') |
| 582 | decodedString = decoder.decode(dataView) |
| 583 | } else { |
| 584 | // Fallback decode as ASCII |
| 585 | let jsonKey: string = ""; |
| 586 | (new Uint8Array(arrayBuffer)).forEach(function (byte: number) { |
| 587 | decodedString += String.fromCharCode(byte); |
| 588 | }) |
| 589 | } |
| 590 | console.debug({ decodedString }) |
| 591 | return decodedString |
| 592 | } |
| 593 | |
| 594 | jsonify (data: any) { |
| 595 | let decodedString |