MCPcopy
hub / github.com/gchq/CyberChef / byteArrayToChars

Method byteArrayToChars

src/core/Utils.mjs:669–679  ·  view source on GitHub ↗

* Converts a charcode array to a string. * * @param {byteArray|Uint8Array} byteArray * @returns {string} * * @example * // returns "Hello" * Utils.byteArrayToChars([72,101,108,108,111]); * * // returns "你好" * Utils.byteArrayToChars([20320,22909]);

(byteArray)

Source from the content-addressed store, hash-verified

667 * Utils.byteArrayToChars([20320,22909]);
668 */
669 static byteArrayToChars(byteArray) {
670 log.debug(`Converting byte array[${byteArray?.length}] to chars`);
671 if (!byteArray || !byteArray.length) return "";
672 let str = "";
673 // Maxiumum arg length for fromCharCode is 65535, but the stack may already be fairly deep,
674 // so don't get too near it.
675 for (let i = 0; i < byteArray.length; i += 20000) {
676 str += String.fromCharCode(...(byteArray.slice(i, i+20000)));
677 }
678 return str;
679 }
680
681
682 /**

Callers 15

convertToByteStringMethod · 0.80
byteArrayToUtf8Method · 0.80
arrayBufferToStrMethod · 0.80
_lenDelimMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
parseQEncodedWordMethod · 0.80
elfHeaderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected