-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement P2419R2 Clarify Handling Of Encodings In Localized Formatting Of chrono
Types
#2977
Conversation
d1fb832
to
ba73f5a
Compare
does this need a __cpp_lib_format bump? |
stl/inc/chrono
Outdated
@@ -5351,6 +5418,24 @@ namespace chrono { | |||
|
|||
_Validate_specifiers(_Spec, _Val); | |||
|
|||
#if defined(_MSVC_EXECUTION_CHARACTER_SET) && _MSVC_EXECUTION_CHARACTER_SET == 65001 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be marked with the same transition comment as _Is_execution_charset_self_synchronizing
in <format>
to remove the
ifdef check once EDG supports this feature.
P2508R1 (Expose std::basic-format-string) updates the same macro. I'll wait until that paper is implemented. |
@cpplearner Just checking on the status of this PR - are you planning to make changes here, or should we mark it as blocked until there's a PR for #2937? |
I thought I made the changes but I forgot to push them 😢 |
@cpplearner Checking again - are your changes ready to push? @barcharcraz and @strega-nil-ms would like to review them 😸 |
I've pushed db93009 after posting #2977 (comment) (GitHub UI is weird). I think this PR is ready for review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now looks good.
I'm still a tiny bit annoyed with the approach of narrowing the wide versions of the locale data, but I can't think of a better way to do it. Maybe I'll make an issue to switch to the UTF-8 locale data once we no longer support systems that lack it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks, although I'm kinda sad for using wostringstream.
LGTM too, thanks @cpplearner! FYI @barcharcraz @strega-nil-ms I pushed a one-line change after you approved, moving the |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for implementing this feature - just in time for 17.4 Preview 3! 😹 ⏱️ 🎉 |
Fixes #2927.
When the literal encoding is UTF-8, This ensures that the strings produced by chrono formatters are always encoded in UTF-8, by first formatting with
wchar_t
, then converting the output to UTF-8. (Is there a better way?)I didn't convert the output of
_Custom_write
, because it seems that_Custom_write
generally does not deal with localized formatting.