| Previous | Next |
| ERROR_DOMAIN_CTRLR_CONFIG_ERROR | ERROR_UNDEFINED_CHARACTER |
ERROR_ILLEGAL_CHARACTER
An illegal character sequence was encountered
ERROR_ILLEGAL_CHARACTER means Windows found a character or byte sequence that is not valid for the active character encoding. For multibyte encodings this can be an incomplete lead byte; for Unicode it can include reserved noncharacters or malformed surrogate sequences.
Typical causes
- Decoding bytes with the wrong code page.
- Truncating a multibyte or UTF sequence in the middle of a character.
- Passing unvalidated external text to a strict conversion API.
- Mixing ANSI and Unicode interfaces or incorrect string lengths.
Diagnosis
Capture the encoding name, byte length, failing offset, and a safe hexadecimal sample around the failure. Do not log sensitive text verbatim. Verify whether lengths are expressed in bytes or characters and whether terminators are included.
Handling
Reject malformed input or use an explicitly documented replacement policy. Avoid silently switching code pages because the same bytes can decode to different text. Preserve original bytes when data must be repaired later.
Developer guidance
Prefer UTF-8 or UTF-16 end to end, validate at system boundaries, and test split buffers, supplementary characters, and invalid sequences.
References
Looking for a different code? Search another status or error code.