| 1469 | return utf8Bytes.toBase64(); | 1469 | return utf8Bytes.toBase64(); |
| 1470 | } | 1470 | } |
| 1471 | // Creates binary string, where each character's code point directly matches the byte value (0-255). | 1471 | // Creates binary string, where each character's code point directly matches the byte value (0-255). |
| 1472 | const binaryString = String.fromCharCode(...utf8Bytes); | 1472 | let binaryString = ''; |
| | 1473 | const chunkSize = 8192; |
| | 1474 | for (let i = 0; i < utf8Bytes.length; i += chunkSize) { |
| | 1475 | binaryString += String.fromCharCode(...utf8Bytes.subarray(i, i + chunkSize)); |
| | 1476 | } |
| 1473 | return window.btoa(binaryString); | 1477 | return window.btoa(binaryString); |
| 1474 | } | 1478 | } |
| 1475 | | 1479 | |