cplusplus / papers

ISO/IEC JTC1 SC22 WG21 paper scheduling and management
678 stars 18 forks source link

P3258 R0 Formatting charN_t #1917

Open wg21bot opened 6 months ago

wg21bot commented 6 months ago

P3258R0 Formatting charN_t (Corentin Jabot)

jensmaurer commented 1 month ago

This adds a definition to the core language and thus needs eventual CWG (but not EWG) review.

tahonermann commented 2 weeks ago

SG16 reviewed P3258R0 during its 2024-11-06 meeting. The following polls were taken:

SG16 was split on support for this proposal vs pursuing only support for charN_t specializations of std::format() and friends (in some future proposal). With respect to formatting values of charN_t types, there are several complementary designs that can support doing so.

  1. Allow the existing char and/or wchar_t specializations of std::format() and friends to format values of charN_t type; the solution proposed in P3258.
  2. Introduce new charN_t specializations of std::format() and friends and allow them to format values of charN_t type, but not values of char or wchar_t type; no existing proposal.

The primary concern raised for the first design, this proposal, is that transcoding the charN_t values to the encoding of char or wchar_t may result in information loss; unrepresentable characters might be substituted with a replacement character (e.g., U+FFFD REPLACEMENT CHARACTER) or escape mechanism (e.g., \u{1234}). Some SG16 members find this to be acceptable; others feel this is contrary to the original intent of std::format() and find the potential information loss unacceptable, even with a graceful degradation approach.

The second design requires solving locale concerns (e.g., introducing charN_t specializations of std::locale facets) or eschewing support for localized formatting (e.g., the L modifier that can be used with many standard formatters).

The implicit third design option is the status quo in which programmers are required to perform transcoding operations on their own.

I'm not convinced that SG16 has exhausted discussion on this proposal, so I'm going to retain the SG16 label for now.