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.

4522. Clarify that std::format transcodes for std::wformat_strings

Section: 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_chars as 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.

During the 2026-02-11 SG16 Telecon, when reviewing P3876R0, SG16 examined this issue and concluded that transcoding is intended here, affirmed by the author of P0645R10 Text Formatting. An LWG issue was requested.

Proposed resolution:

This wording is relative to N5032.

  1. 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 to_chars. In such cases, let [first, last) be a range large enough to hold the to_chars output and value be the formatting argument value. Formatting is done as if by calling to_chars as specified , transcoding the to_chars output to the wide literal encoding if charT is wchar_t, and copying the output through the output iterator of the format context.

    [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]