Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 13 Jun 2023 01:09:26 +0200
From: Bruno Haible <bruno@...sp.org>
To: Rich Felker <dalias@...c.org>
Cc: musl@...ts.openwall.com
Subject: Re: swprintf cannot handle the character 0xff

Rich Felker wrote:
> However, for wide printf:
> 
>     c
>     If no l (ell) qualifier is present, the int argument shall be
>     converted to a wide character as if by calling the btowc()
>     function and the resulting wide character shall be written.
> 
> There's no specification of what happens if btowc fails here, but
> passing EOF to btowc is required to fail and return WEOF.

Possibly. But in the test program that I provided, I pass 255, not
-1 (= EOF).

It's well-known that the preferred way to convert a 'char' to 'int'
is not by direct assigment/cast, but by casting to 'unsigned char'.
That's well-known from [f]getc(), the <ctype.h> functions, etc.
You don't need to particularly care about programmers who pass
'\xff' to a function that expects an 'int'.

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.