This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
std::format transcodes for std::wformat_stringsSection: 28.5.2.2 [format.string.std] Status: New Submitter: Jan Schultke Opened: 2026-02-12 Last modified: 2026-02-14
Priority: Not Prioritized
View other active issues in [format.string.std].
View all other issues in [format.string.std].
View all issues with New status.
Discussion:
The current wording in 28.5.2.2 [format.string.std] paragraph 20 suggests that
the expression format(L"{}", 0) could produce a garbage or malformed string:
[…] Formatting is done as if by calling
to_charsas specified and copying the output through the output iterator of the format context.
It is not stated that transcoding takes place, so a plausible interpretation is that the output of
to_chars is copied to the output iterator directly. If the ordinary literal encoding is, say,
EBCDIC and the wide literal encoding is, say, UTF-32, simply converting char to wchar_t is
not meaningful.
Proposed resolution:
This wording is relative to N5032.
Modify 28.5.2.2 [format.string.std] as indicated:
[Drafting note: 28.5.6.5 [format.string.escaped] paragraph 2 similarly references the wide literal encoding (as the associated character encoding for
charT = wchar_t. ]
-20- The meaning of some non-string presentation types is defined in terms of a call to
[Note 7: Additional padding and adjustments are performed prior to copying the output through the output iterator as specified by the format specifiers. — end note]to_chars. In such cases, let[first, last)be a range large enough to hold theto_charsoutput and value be the formatting argument value. Formatting is done as if by callingto_charsas specified , transcoding theto_charsoutput to the wide literal encoding ifcharTiswchar_t, and copying the output through the output iterator of the format context.