happy-codec
    Preparing search index...

    Function encodeByteString

    • 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.

      Parameters

      • data: DataSource

        The string or BufferSource to encode.

      Returns string

      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