{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/34485","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/34485/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/34485/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/34485/events","html_url":"https://github.com/rust-lang/rust/pull/34485","id":162328280,"number":34485,"title":"Escape fewer Unicode codepoints in `Debug` impl of `str`","user":{"login":"tbu-","id":6666593,"avatar_url":"https://avatars.githubusercontent.com/u/6666593?v=3","gravatar_id":"","url":"https://api.github.com/users/tbu-","html_url":"https://github.com/tbu-","followers_url":"https://api.github.com/users/tbu-/followers","following_url":"https://api.github.com/users/tbu-/following{/other_user}","gists_url":"https://api.github.com/users/tbu-/gists{/gist_id}","starred_url":"https://api.github.com/users/tbu-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbu-/subscriptions","organizations_url":"https://api.github.com/users/tbu-/orgs","repos_url":"https://api.github.com/users/tbu-/repos","events_url":"https://api.github.com/users/tbu-/events{/privacy}","received_events_url":"https://api.github.com/users/tbu-/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-nominated","name":"I-nominated","color":"e10c02"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/T-libs","name":"T-libs","color":"bfd4f2"}],"state":"open","locked":false,"assignee":{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false},"assignees":[{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false}],"milestone":null,"comments":25,"created_at":"2016-06-26T13:40:52Z","updated_at":"2016-06-29T08:05:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/34485","html_url":"https://github.com/rust-lang/rust/pull/34485","diff_url":"https://github.com/rust-lang/rust/pull/34485.diff","patch_url":"https://github.com/rust-lang/rust/pull/34485.patch"},"body":"Use the same procedure as Python to determine whether a character is\r\nprintable, described in [PEP 3138]. In particular, this means that the\r\nfollowing character classes are escaped:\r\n\r\n- Cc (Other, Control)\r\n- Cf (Other, Format)\r\n- Cs (Other, Surrogate), even though they can't appear in Rust strings\r\n- Co (Other, Private Use)\r\n- Cn (Other, Not Assigned)\r\n- Zl (Separator, Line)\r\n- Zp (Separator, Paragraph)\r\n- Zs (Separator, Space), except for the ASCII space `' '` `0x20`\r\n\r\nThis allows for user-friendly inspection of strings that are not\r\nEnglish (e.g. compare `\"\\u{e9}\\u{e8}\\u{ea}\"` to `\"éèê\"`).\r\n\r\nFixes #34318.\r\nCC #34422.\r\n\r\n[PEP 3138]: https://www.python.org/dev/peps/pep-3138/"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/229285572","html_url":"https://github.com/rust-lang/rust/pull/34485#issuecomment-229285572","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/34485","id":229285572,"user":{"login":"ranma42","id":1506030,"avatar_url":"https://avatars.githubusercontent.com/u/1506030?v=3","gravatar_id":"","url":"https://api.github.com/users/ranma42","html_url":"https://github.com/ranma42","followers_url":"https://api.github.com/users/ranma42/followers","following_url":"https://api.github.com/users/ranma42/following{/other_user}","gists_url":"https://api.github.com/users/ranma42/gists{/gist_id}","starred_url":"https://api.github.com/users/ranma42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranma42/subscriptions","organizations_url":"https://api.github.com/users/ranma42/orgs","repos_url":"https://api.github.com/users/ranma42/repos","events_url":"https://api.github.com/users/ranma42/events{/privacy}","received_events_url":"https://api.github.com/users/ranma42/received_events","type":"User","site_admin":false},"created_at":"2016-06-29T08:05:13Z","updated_at":"2016-06-29T08:05:13Z","body":"To me, the major advantage of the current implementation of `Debug` for `str` (always escaping non-ASCII) is that it allows to distinguish between different strings that have the same visual appearance. This applies in the same way to whitespace ('\\t' vs spaces), Unicode combining characters and control characters... and maybe more?\r\n\r\nOf course this does not mean that it should be used for everything. Specifically, I would only use `Debug` when the *representation* of the data is relevant, not when it just needs to be shown to the user. Basically this reasoning is my understanding of the documentation of `Debug` and `Display` (programmer-facing vs user-facing). This can of course be incorrect, but in that case I would also ask for an improvement in the documentation ;)\r\n\r\n#34318 shows an example where using `Debug` looks inappropriate (an OS-provided localised error). A partial solution that would have limited impact on other things would be to avoid escaping *only* the OS localised errors [here](https://github.com/rust-lang/rust/blob/master/src/libstd/io/error.rs#L285). I would not even call this a breaking change, given that the output is already not explicitly stabilised (it obviously depends on the current locale and most likely on the operating system + version).\r\n\r\nEven though Rust does not (yet) have its own localised error messages, it would not be hard to imagine the same issue affecting other types of output, so it might be a good idea to think of a more general solution to ensure a way forward in this direction."}}
{"actor":{"display_login":"ranma42"}}