[PATCH 3/6] Make fflush (NULL) flush input files (bug 32369)
Joseph Myers
josmyers@redhat.com
Thu Jan 16 00:28:36 GMT 2025
On Wed, 15 Jan 2025, DJ Delorie wrote:
> Joseph Myers <josmyers@redhat.com> writes:
> > That's simply how all the wide I/O functions work.
>
> I'm not doubting the test's correctness or now the functions run, I'm
> just saying I was surprised that it did a wide->multi conversion. And
> IMHO when someone reading code is surprised, that's a good spot for a
> comment ;-)
I'm thinking of this as something basic from the description of files in
the C standard (C23 7.23.3; two paragraphs "The wide character input
functions read multibyte characters from the stream and convert them to
wide characters as if ..." and "The wide character output functions
convert wide characters to multibyte characters and write them to the
stream as if ..."), so not worthy of remark in the context of an
individual test.
> > This test is using the C locale; since it's only using ASCII characters,
> > no specific locale is needed. A null character can't be part of another
> > multibyte character, which means that UTF-16 and UTF-32 are not possible
> > locale multibyte encodings to write out to the file.
>
> Do we have an API that can write UTF-16 or UTF-32 encodings to files?
> Or do they devolve to using the regular fwrite et al?
You'd need to use fwrite. Text files are made up of multibyte characters.
--
Joseph S. Myers
josmyers@redhat.com
More information about the Libc-alpha
mailing list