MCPcopy Create free account
hub / github.com/ampproject/amphtml / bytesToString

Function bytesToString

third_party/subscriptions-project/swg-gaa.js:361–369  ·  view source on GitHub ↗

* Converts a 8-bit bytes array into a string * @param {!Uint8Array} bytes * @return {string}

(bytes)

Source from the content-addressed store, hash-verified

359 * @return {string}
360 */
361function 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.

Callers 1

utf8DecodeSyncFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected