Implement the ? format specifier for strings and characters#3656
Merged
CaseyCarter merged 21 commits intomicrosoft:mainfrom May 18, 2023
Merged
Implement the ? format specifier for strings and characters#3656CaseyCarter merged 21 commits intomicrosoft:mainfrom
? format specifier for strings and characters#3656CaseyCarter merged 21 commits intomicrosoft:mainfrom
Conversation
4448022 to
cc9aabc
Compare
barcharcraz
reviewed
Apr 18, 2023
barcharcraz
suggested changes
Apr 19, 2023
tools/unicode_properties_parse/grapheme_break_property_data_gen.py
Outdated
Show resolved
Hide resolved
barcharcraz
reviewed
May 4, 2023
barcharcraz
reviewed
May 4, 2023
Comment on lines
+1681
to
+1685
| #if _HAS_CXX23 | ||
| case '?': | ||
| _Cat = _Presentation_type_category::_Escape; | ||
| break; | ||
| #endif // _HAS_CXX23 |
Contributor
There was a problem hiding this comment.
Potential future improvement:
We could recognize this in c++20 and earlier modes and emit a helpful diagnostic.
barcharcraz
approved these changes
May 4, 2023
StephanTLavavej
requested changes
May 12, 2023
This comment was marked as resolved.
This comment was marked as resolved.
StephanTLavavej
approved these changes
May 13, 2023
Member
|
FYI @barcharcraz, changes have been pushed since your approval but they were minor so I don't think you need to take another look. |
Member
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Contributor
|
Thanks for implementing this sub-feature, which is not questionable in any way! |
JMazurkiewicz
added a commit
to JMazurkiewicz/STL
that referenced
this pull request
Jul 30, 2023
* This PR implements debug-enabled standard `formatter` specializations, * Drive-by: rename tests added in microsoft#3656 - use `text_formatting_` prefix instead of `formatting_ranges_` (for consistency), * Towards microsoft#2919.
JMazurkiewicz
added a commit
to JMazurkiewicz/STL
that referenced
this pull request
Jul 30, 2023
* This PR implements debug-enabled standard `formatter` specializations, * Drive-by: rename tests added in microsoft#3656 - use `text_formatting_` prefix instead of `formatting_ranges_` (for consistency), * Towards microsoft#2919.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements [format.string.escaped], which is part of WG21-P2286R8 "Formatting Ranges" and modified by WG21-P2713R1 "Escaping Improvements In
std::format". Works towards #2919.To implement this feature, two arrays,
__printable_rangesand_Grapheme_Extend_ranges, are added to__msvc_format_ucd_tables.hpp.__printable_rangesrepresents code points whoseGeneral_Categoryis in the groupsL,M,N,P,S(that is, code points that are not from categoriesZorC), plus the ASCII space character.\u{hex-digit-sequence}format. ([format.string.escaped]/(2.2.1.2.1))General_Category, instead of this invented property. This requires more storage and a new data structure, though._Grapheme_Extend_rangesrepresents code points with the Unicode propertyGrapheme_Extend=Yes.Grapheme_Cluster_Break:Grapheme_Extend=YesisGrapheme_Cluster_Break=ExtendminusEmoji_Modifier=Yes, andEmoji_Modifier=Yesis just1F3FB..1F3FF. I chose to define a new array for simplicity.When the literal encoding is not UTF-8, UTF-16, or UTF-32, the set of "separator or non-printable characters" is implementation-defined. In this implementation, the set consists of all characters that correspond to non-printable Unicode code points (that is, code points outside of
__printable_ranges, see above). If a character is non-printable, it is translated into\u{XXXX}, whereXXXXis the hex value of the Unicode code point (not the original value).If a code unit sequence cannot be converted to a Unicode scalar value, the
\x{XX}escape sequence is used.