happy-codec
    Preparing search index...

    Function encodeHex

    • Encodes DataSource to a hexadecimal string.

      • String: First UTF-8 encoded, then converted to hexadecimal
      • BufferSource: Directly converted to hexadecimal

      Uses native Uint8Array.prototype.toHex if available, otherwise pure JS fallback.

      Parameters

      Returns string

      Hexadecimal string.

      If the input is not a string, ArrayBuffer, or ArrayBufferView.

      1.0.0

      const hex = encodeHex(new Uint8Array([255, 0, 128]));
      console.log(hex); // 'ff0080'

      const hex2 = encodeHex('hello');
      console.log(hex2); // '68656c6c6f'