Behavior of extended bytes/characters in C/POSIX locale

c, character-encoding, locale, posix

Solution

From your comment to the previous answer:

The ways in which the assumption could be wrong are basically that bytes outside the portable character set could be illegal non-character bytes (EILSEQ) or make up some multibyte encoding (UTF-8 or a stateless legacy CJK encoding)

Here you can find one example.

Plan 9 only supports the "C" locale. As you can see in utf.c and rune.c, when it find a rune outside the portable characters, it simply handles it as a character from a different encoding.

Another candidates could be Minix and the *BSD family (as far as they use citrus). In the Minix source code I've also found the file command looking for new encoding when the character size is not 8bit.

Problem

C and POSIX both require only a very limited set of characters be present in the C/POSIX locale, but allow additional characters to exist. This leaves a great deal of freedom to the implementation; for instance, supporting all of Unicode (as UTF-8) in the C locale is conforming behavior. However, most historical implementations treat the C locale as having an "8-bit-clean" single-byte character encoding, either ISO-8859-1 (Latin-1) or a sort of "abstract 8-bit character set" where the non-ASCII bytes are abstract characters with no particular identity. (However, in the latter case, if the compiler defines `__STDC_ISO_10646__`, they normatively correspond to Unicode characters, usually the Latin-1 range.) Another conforming option that seems much less popular is to treat all non-ASCII bytes as non-characters, i.e. respond to them with an `EILSEQ` error. What I'm interested in knowing is whether there are implementations which take this or any other unusual options in implementing the C locale. Are there implementations where attempting to convert "high bytes" in the C locale results in `EILSEQ` or anything other than treating them as (abstract or Latin-1) single-byte characters or UTF-8?

Original source

Related problems