@svta/common-media-library
    Preparing search index...

    Function dataViewToString

    • Beta

      Converts a DataView to a string.

      Parameters

      • dataView: DataView

        The DataView to convert.

      • encoding: Encoding = UTF_8

        The encoding to use.

      Returns string

      The string representation of the DataView.

      const str = 'hello world';
      const codes = strToCodes(str);
      const buffer = new ArrayBuffer(codes.length);
      const dataView = new DataView(buffer);

      // Fill DataView with string data
      for (let i = 0; i < codes.length; i++) {
      dataView.setUint8(i, codes[i]);
      }

      equal(dataViewToString(dataView, UTF_8), str);