Uh oh!
There was an error while loading. Please reload this page.
Escape combining characters in char::Debug - #49283
Conversation
clarfonthey
commented
Mar 22, 2018
LGTM although the character ranges should probably be generated with a script instead of hard-coded, as they can change across unicode versions. |
varkor
commented
Mar 23, 2018
@clarcharr: have you got any ideas for how to detect ranges programmatically? Apart from parsing the Unicode symbol names (which does not seem robust), I couldn't find any reasonable suggestion for how to do this automatically. |
alexcrichton
commented
Mar 23, 2018
r? @SimonSapin |
SimonSapin
commented
Mar 23, 2018
This PR is modifying the However this method is also used in Regarding this being a breaking change, I think I’d be ok with documenting that the exact set of code points being escaped or not is not stable outside of the ASCII range. The current doc-comment is already out of sync with the implementation: it claims that anything non-ASCII is escaped, which hasn’t been the case since #34485. I also agree with not hard-coding code point ranges, and instead extracting more Unicode data in
Then there’s the
However #41922 suggests that only nonspacing marks are problematic? |
clarfonthey
commented
Mar 23, 2018
I'd be fine with just going for nonspacing marks. As for |
varkor
commented
Mar 26, 2018
Yeah, I'm not sure about this. It'd be nicer if there was an extra argument (
Which doc comment are you referring to here?
I have a change that uses |
varkor
commented
Apr 4, 2018
@SimonSapin: as far as I can tell, there's an issue using |
clarfonthey
commented
Apr 5, 2018
Wasn't the goal of having Personally I really dislike the |
SimonSapin
commented
Apr 5, 2018
#49698 merges It might be interesting to replace |
bors
commented
Apr 12, 2018
☔ The latest upstream changes (presumably #49698) made this pull request unmergeable. Please resolve the merge conflicts. |
fb39348 to
a1c6debComparevarkor
commented
Apr 12, 2018
@SimonSapin: #49698 makes everything much more pleasant :) I've rebased on top of it (and also cleaned up |
SimonSapin
commented
Apr 12, 2018
@varkor Thanks for your work on this. However I’m still not sure what the right thing to do here is, in terms of what characters exactly to escape or not in which context. Do you know what other languages do for debug-printing Unicode strings and characters? |
varkor
commented
Apr 12, 2018
@SimonSapin: Swift does something similar to the proposed change here. I haven't tried working out exactly which characters they choose to escape, but it seems reasonable to assume they choose either the same, or a similar category. |
varkor
commented
Apr 12, 2018
Ah, so Swift actually escapes any non-ASCII character, which is what Rust used to do before #24588: |
672b39f to
59513adCompare59513ad to
c85cc88Comparec85cc88 to
e96a115CompareTimNN
commented
Apr 17, 2018
@SimonSapin: Friendly triage ping :) |
3591ecd to
2fa22efCompareSimonSapin
commented
May 21, 2018
@bors r+ |
bors
commented
May 21, 2018
📌 Commit b653937 has been approved by |
bors
commented
May 21, 2018
Escape combining characters in char::Debug Although combining characters are technically printable, they make little sense to print on their own with `Debug`: it'd be better to escape them like non-printable characters. This is a breaking change, but I imagine the fact `escape_debug` is rare and almost certainly primarily used for debugging that this is an acceptable change. Resolves#41922. r? @alexcrichton cc @clarcharr
bors
commented
May 22, 2018
☀️ Test successful - status-appveyor, status-travis |
Although combining characters are technically printable, they make little sense to print on their own with
Debug: it'd be better to escape them like non-printable characters.This is a breaking change, but I imagine the fact
escape_debugis rare and almost certainly primarily used for debugging that this is an acceptable change.Resolves#41922.
r? @alexcrichton
cc @clarcharr