std::vprint_unicode, std::vprint_unicode_buffered

Header: <print>

Format args according to the format string fmt, and writes the result to the output stream.

# Declarations

void vprint_unicode( std::FILE* stream,
std::string_view fmt, std::format_args args );

(since C++23)

void vprint_unicode_buffered( std::FILE* stream,
std::string_view fmt, std::format_args args );

(since C++23)

void vprint_unicode_buffered( std::string_view fmt, std::format_args args );

(since C++23)

# Parameters

# Notes

The C++ standard encourages the implementers to produce a diagnostic message if out contains invalid Unicode code units.

On POSIX, writing to a terminal is done using the usual standard I/O functions, so there is no need to treat a terminal differently to any other file stream.

On Windows, the stream refers to a terminal if GetConsoleMode(_get_osfhandle(_fileno(stream))) returns nonzero (see Windows documentation for GetConsoleMode, _get_osfhandle, and _fileno). The native Unicode API on Windows is WriteConsoleW.

If invoking the native Unicode API requires transcoding, the invalid code units are substituted with U+FFFD REPLACEMENT CHARACTER (see “The Unicode Standard - Core Specification”, Chapter 3.9).

# Example

This section is incompleteReason: no example

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 4044C++23the native Unicode API was always used if theterminal referred to by stream can display Unicodeonly used if the terminal can only usethe native Unicode API to display Unicode
P3107R5C++23printing operations were always bufferedprovides unbuffered printing operations
P3235R3C++23the names of the functions addedby P3107R5 were misleadingchanged the function names

# See also