DecodeTextOptions
DecodeTextOptions =
object
Defined in: packages/core/src/buffer/text/decode-text.ts:27
Options mirroring TextDecoderOptions (see TextDecoder).
Only "utf-8" and "utf-16be" honor both options — they are the only two
encodings here backed by a real TextDecoder instance, and per the WHATWG
Encoding Standard, BOM handling and the fatal/replacement error modes are
likewise only defined for UTF-8 and UTF-16BE/LE.
"latin1"/"ascii" ignore both options: they are deliberately not the
WHATWG-spec "latin1"/"ascii" labels, which the standard defines as
aliases for windows-1252 (remapping bytes 0x80-0x9F to printable characters)
— these decode every byte 1:1 to its own code point instead, matching true
ISO-8859-1/ASCII. Neither option has a meaning for that mapping: every byte
is valid, and there is no byte order mark for a single-byte encoding.
"utf-32be" ignores ignoreBOM (no byte order mark exists for a
4-byte-per-code-point scheme) but honors fatal, since a 4-byte group can
still decode to a surrogate or an out-of-range value.
"windows-1252" and "shift_jis" are decoded by a real TextDecoder too:
they honor fatal and ignore ignoreBOM, which the standard defines for
Unicode encodings only. Every windows-1252 byte decodes, so fatal never
throws for it.
Properties
Section titled “Properties”fatal?
Section titled “fatal?”
optionalfatal?:boolean
Defined in: packages/core/src/buffer/text/decode-text.ts:32
When true, throw a TypeError on invalid input instead of substituting
U+FFFD. Defaults to false, matching TextDecoder.
ignoreBOM?
Section titled “ignoreBOM?”
optionalignoreBOM?:boolean
Defined in: packages/core/src/buffer/text/decode-text.ts:39
When false (the default), a leading byte order mark is consumed and
dropped rather than decoded as U+FEFF. Defaults to false, matching
TextDecoder.