On 7/12/21 5:33 PM, Victor Zverovich via SG16 wrote:
Thanks, Corentin, that's a great find. This is indeed very close to what is proposed and a nice addition to the implementation experience in {fmt} and Rust.

There are some notable differences relative to what we've been discussing.

  1. The LLVM implementation has a wide contract; there is no UB if the input is not valid UTF-8.
  2. If the provided text is not valid UTF-8, then the raw input is written through the file descriptor rather than being transcoded to UTF-16 with substitution characters and then written directly to the console.

Tangent: the method LLVM is using to determine if a file descriptor corresponds to a console looks wrong to me and, I think, will result in attempts to write text to the console when it was actually directed elsewhere.  Such writes likely fail with the result that the original input ends up getting written to the file descriptor anyway.  We previously discussed how to detect output directed to a console here (and some day we'll have email archives that aren't embarrassing.  I hope).

Tom.


Cheers,
Victor

On Mon, Jul 12, 2021 at 1:59 PM Corentin via SG16 <sg16@lists.isocpp.org> wrote:
Hello,

LLVM implemented exactly what is proposed by std::print 3 years ago
https://github.com/llvm-mirror/llvm/blob/master/lib/Support/raw_ostream.cpp#L638-L685

I thought this might be of interest.

Regards, 
Corentin
--
SG16 mailing list
SG16@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/sg16