| Previous | Next |
| EUNATCH | EIDRM |
EILSEQ
EILSEQ is a character-encoding failure. It means the bytes being converted do not form a valid sequence under the active conversion rules; it does not by itself identify the intended source encoding. The same payload can succeed under one locale or explicit encoding and fail under another.
In the UCRT, multibyte conversion functions such as mbsrtowcs and mbrlen can set errno to EILSEQ when an input sequence has no valid multibyte interpretation. A failed restartable conversion can also leave the conversion state unsuitable for reuse, so treating the failure as “skip one byte and continue” risks corrupting data or losing position information.
Make the failure reproducible
- Record the declared or assumed encoding, locale, exact byte offset, a bounded escaped byte sample, and whether input arrived in chunks.
- Keep conversion state per stream; do not share one mutable
mbstate_tacross unrelated byte sequences. - Distinguish an incomplete sequence at a chunk boundary from an invalid sequence. The recovery policy can be different.
- Use an explicit Unicode conversion boundary for network and file formats instead of relying on the machine's current code page.
References
Looking for a different code? Search another status or error code.