sheng-tool
    Preparing search index...

    Function decodeUtf8Text

    • 将字节严格解码为 UTF-8 文本。

      默认移除开头的 BOM。需要保留文本首字符或按原字节写回文件时,可以显式保留 BOM。

      Parameters

      • bytes: Uint8Array

        UTF-8 字节。传入视图时只读取该视图覆盖的字节。

      • options: { preserveBom?: boolean } = {}

        传入 preserveBom: true 时保留开头的 BOM。

      Returns string

      解码得到的文本。

      字节序列不是合法的 UTF-8 时抛出 TypeError。

      0.2.0

      decodeUtf8Text(new Uint8Array([0xef, 0xbb, 0xbf, 0x41]))  // 'A'
      decodeUtf8Text(new Uint8Array([0xff])) // throws TypeError