Encodes a string or BufferSource to a byte string, with each byte as a character.
Uses String.fromCharCode.apply in chunks of 8192 bytes for efficient batch conversion while staying safe from call-stack overflow.
String.fromCharCode.apply
The string or BufferSource to encode.
Byte string.
If the input is not a string, ArrayBuffer, or ArrayBufferView.
1.0.0
const str = encodeByteString(new Uint8Array([72, 101, 108, 108, 111]));console.log(str); // 'Hello'const byteStr = encodeByteString('你好');// Returns the UTF-8 encoded byte string Copy
const str = encodeByteString(new Uint8Array([72, 101, 108, 108, 111]));console.log(str); // 'Hello'const byteStr = encodeByteString('你好');// Returns the UTF-8 encoded byte string
Encodes a string or BufferSource to a byte string, with each byte as a character.
Uses
String.fromCharCode.applyin chunks of 8192 bytes for efficient batch conversion while staying safe from call-stack overflow.