Re: wctomb() accepts out-of-range character in C-locale

[email protected]
Newsgroups gmane.comp.lib.newlib
Organization Systematic Software
Message-ID <[email protected]>
On 2024-03-25 08:07, Jun. T wrote:
> 
>> 2024/03/25 20:26, Bruno Haible <[email protected]> wrote:
>>
>>>> But a wide character >= 0x80 can't be converted into a valid
>>>> character in C-loccale (7bit), I think.
>>
>> Err. "C" locale, a.k.a. "POSIX" locale, is not 7-bit but 8-bit.
>> Quoting https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap06.html#tag_06_02 :
>>   "The POSIX locale shall contain 256 single-byte characters ..."
> 
> I still can't understand why it is useful to convert wide char
> in the range 0x80-0xff to an 8bit char in C-locale (for example
> convert wide char 0xe1 (U+00e1) = á to an 8bit char 0xe1).

Before Unicode, UCS, and UTF character sets, European Single Byte Character Sets 
such as ISO-8859-* were used for Latin script based languages, including most 
programming languages, with accented characters mainly in the high half, and 
supported (most of) the POSIX character set; whereas Arabic, Cyrillic, Greek, 
Hebrew, other Asian and Indian, and CJK Han script based languages used some 
local SBCS, fuller featured Double Byte Character Sets, and Multi Byte Character 
Sets, some of which supported (parts of) the POSIX character set, and used shift 
characters to switch to characters encoded using the second and other bytes.

For more info see https://en.wikipedia.org/wiki/SBCS and linked articles.

 > But if you say this is THE correct behavior then it's OK.

POSIX says it, so by definition, it's OK! ;^>

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.