Utf8CodecConfig

type Utf8CodecConfig = object;

Defines the configuration options for UTF-8 codecs.

Properties

fatal?

optional fatal?: boolean;

Whether to throw on invalid UTF-8 instead of silently substituting the replacement character (U+FFFD).

When encoding, strings containing lone surrogates are rejected. When decoding, malformed byte sequences are rejected.

Default Value

false


ignoreBOM?

optional ignoreBOM?: boolean;

Whether to keep a leading byte order mark (U+FEFF) in decoded strings.

By default, a leading byte order mark is stripped, as TextDecoder does. Only applies when decoding.

Default Value

false


removeNullCharacters?

optional removeNullCharacters?: boolean;

Whether to strip null characters (\u0000) from decoded strings.

This is useful when decoding fixed-size strings that are padded with null characters, but it makes the codec lossy for strings that legitimately contain null characters. Only applies when decoding.

Default Value

true

On this page