* Converts a 8-bit bytes array into a string * @param {!Uint8Array} bytes * @return {string}
(bytes)
| 359 | * @return {string} |
| 360 | */ |
| 361 | function bytesToString(bytes) { |
| 362 | // Intentionally avoids String.fromCharCode.apply so we don't suffer a |
| 363 | // stack overflow. #10495, https://jsperf.com/bytesToString-2 |
| 364 | const array = new Array(bytes.length); |
| 365 | for (let i = 0; i < bytes.length; i++) { |
| 366 | array[i] = String.fromCharCode(bytes[i]); |
| 367 | } |
| 368 | return array.join(''); |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * Interpret a byte array as a UTF-8 string. |