Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 12 Jun 2023 22:53:24 +0200
From: Bruno Haible <bruno@...sp.org>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com
Subject: Re: swprintf %lc directive does not work for some wide characters

Rich Felker wrote:
> Per my reading of the specification, this is not a bug but is the
> expected behavior.
> 
>     In addition, all forms of fwprintf() shall fail if:
> 
>     [EILSEQ]
>             A wide-character code that does not correspond to a valid
>             character has been detected.

From my reading of ISO C, it's a bug. Namely, in ISO C 23 ยง 7.31.2.3
the error conditions are specified as
  "The swprintf function returns the number of wide characters written
   in the array, not counting the terminating null wide character,
   or a negative value if
     an encoding error occurred
     or if n or more wide characters were requested to be written."

In swprintf, where "the wint_t argument converted to wchar_t" is written
and the output is to a wchar_t[], no "encoding error" should be possible.
That's obvious. The "encoding errors" occur in %c and %s directives,
AFAIU, not in %lc and %ls directives.

Bruno



Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.