Table of Contents

Enum InvalidTextHandling

Namespace
CStructSharp
Assembly
CStructSharp.dll

Chooses what a read does with text that is not valid in its encoding.

public enum InvalidTextHandling

Fields

Fail = 0

The read fails with CStructReadException naming the field; this is the default.

Replace = 1

Each invalid byte sequence (UTF-8), unpaired surrogate (UTF-16), or non-ASCII byte (cstring and the other ASCII strings) becomes U+FFFD, the Unicode replacement character, and the read continues. Terminators, lengths and read budgets are unaffected.

Remarks

The choice applies to every text type that can hold invalid data: utf8 and utf16le/utf16be buffers, wchar[N] arrays, and terminated strings (cstring, utf8_string_zero, string, ...). latin1, cp437, and char[N] map every byte to a character, so they never fail.

Replace loses the original bytes: two different invalid sequences read as the same replacement character. A generated view keeps them reachable, because each text member also exposes its bytes.