I/O manipulators | ||||
Print functions(C++23) | ||||
C-style I/O | ||||
Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
Streams | ||||
Abstractions | ||||
File I/O | ||||
String I/O | ||||
Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
Synchronized Output | ||||
(C++20) | ||||
Types | ||||
Error category interface | ||||
(C++11) | ||||
(C++11) |
Print functions | ||||
(C++23) | ||||
(C++23) | ||||
vprint_unicodevprint_unicode_buffered (C++23)(C++23) | ||||
(C++23)(C++23) |
Defined in header <print> | ||
void vprint_unicode(std::FILE* stream, std::string_view fmt,std::format_args args); | (1) | (since C++23) |
void vprint_unicode_buffered(std::FILE* stream, std::string_view fmt,std::format_args args); | (2) | (since C++23) |
void vprint_unicode_buffered(std::string_view fmt,std::format_args args); | (3) | (since C++23) |
Formatargs according to the format stringfmt, and writes the result to the output stream.
After writing characters to the output stream, establishes anobservable checkpoint. | (since C++26) |
Contents |
stream | - | output file stream to write to | ||||||||||||||||||||||||||||||||||||||||||||||
fmt | - | an object that represents the format string. The format string consists of
Each replacement field has the following format:
1) replacement field without a format specification 2) replacement field with a format specification
| ||||||||||||||||||||||||||||||||||||||||||||||
args | - | arguments to be formatted |
The C++ standard encourages the implementers to produce a diagnostic message ifout 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 ifGetConsoleMode(_get_osfhandle(_fileno(stream))) returns nonzero (see Windows documentation forGetConsoleMode
,_get_osfhandle
, and_fileno
). The native Unicode API on Windows isWriteConsoleW
.
If invoking the native Unicode API requires transcoding, the invalid code units are substituted withU+FFFD
REPLACEMENT CHARACTER (see "The Unicode Standard - Core Specification",Chapter 3.9).
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_print | 202207L | (C++23) | Formatted output |
202403L | (C++26) (DR23) | Unbuffered formatted output | |
202406L | (C++26) (DR23) | Enabling unbuffered formatted output for more formattable types | |
__cpp_lib_format | 202207L | (C++23) | Exposingstd::basic_format_string |
This section is incomplete Reason: no example |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 4044 | C++23 | the native Unicode API was always used if the terminal referred to bystream can display Unicode | only used if the terminal can only use the native Unicode API to display Unicode |
P3107R5 | C++23 | printing operations were always buffered | provides unbuffered printing operations |
P3235R3 | C++23 | the names of the functions added byP3107R5 were misleading | changed the function names |
prints tostdout or a file stream usingtype-erased argument representation (function)[edit] | |
(C++23) | performs Unicode aware output usingtype-erased argument representation (function)[edit] |
(C++23) | prints tostdout or a file stream usingformatted representation of the arguments (function template)[edit] |
(C++20) | stores formatted representation of the arguments in a new string (function template)[edit] |
1. | Unicode |
2. | The Unicode Standard Version 14.0 - Core Specification |