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.

4421. Clarify the output encoding of to_chars for integers

Section: 28.2.2 [charconv.to.chars] Status: New Submitter: Jan Schultke Opened: 2025-10-17 Last modified: 2025-10-23

Priority: 3

View all issues with New status.

Discussion:

The integer overload of to_chars is specified "manually" rather than in terms of printf, and it is not clearly stated what encoding the output characters have. Given the existing use of the character literal '-' in the Effects element, the intent is presumably to output in the ordinary literal encoding.

[2025-10-23; Reflector poll.]

Set priority to 3 after reflector poll.

Concerns with meaning of 'a'..'z' for EBCDIC. Suggestion to use U+0061..U+007A like in [tab:lex.charset.basic], as alternative.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 28.2.2 [charconv.to.chars] as indicated:

    constexpr to_chars_result to_chars(char* first, char* last, integer-type value, int base = 10);
    

    -4- Preconditions: base has a value between 2 and 36 (inclusive).

    -5- Effects: The value of value is converted to a string of digits in the given base (with no redundant leading zeroes) in the ordinary literal encoding (5.3.1 [lex.charset]). Digits in the range 10..35 (inclusive) are represented as lowercase characters 'a'..'z'. If value is less than zero, the representation starts with '-'.