bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %lc/%ls print nothing in C locale if argument has bytes >7f


From: Chet Ramey
Subject: Re: %lc/%ls print nothing in C locale if argument has bytes >7f
Date: Mon, 11 Mar 2024 10:58:27 -0400
User-agent: Mozilla Thunderbird

On 3/8/24 10:56 AM, Emanuele Torre wrote:
Hello.

I have noticed that, in C locale, %lc prints nothing if the first byte
of the argument is non-ASCII (0x80-0xff).

Only on Linux, and maybe other systems that prefer precomposed unicode
characters. (NFC/NFD is kind of a mess, and has been discussed here
previously.)

The issue is that glibc wc[r]tomb/wcs[r]tombs return -1/EILSEQ when
supplied a wide character in a locale where MB_CUR_MAX == 1. Other
systems (macOS) store a single byte in the returned string. printf
converts the supplied multibyte character string to a wide character
string to get the precision right, then converts it back, which is
how these functions are involved.

Maybe printf should just ignore the `l' modifier and treat %C/%S like
%c/%s if MB_CUR_MAX == 1.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]