The Wayback Machine - https://web.archive.org/web/20201016172736/https://github.com/ziglang/zig/pull/6218
Skip to content
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

std: add fmt option to escape non-printable characters #6218

Merged
merged 1 commit into from Sep 2, 2020

Conversation

@daurnimator
Copy link
Collaborator

@daurnimator daurnimator commented Aug 31, 2020

No description provided.

@data-man

This comment has been hidden.

@daurnimator daurnimator force-pushed the daurnimator:fmt-non-printable branch from 7104301 to 90b1aed Aug 31, 2020
@@ -599,6 +600,16 @@ pub fn formatText(
try formatInt(c, 16, fmt[0] == 'X', FormatOptions{ .width = 2, .fill = '0' }, writer);
}
return;
} else if (comptime (std.mem.eql(u8, fmt, "e") or std.mem.eql(u8, fmt, "E"))) {
for (bytes) |c| {
if (std.ascii.isPrint(c)) {

This comment has been minimized.

@Vexu

Vexu Aug 31, 2020
Member

Do we consider \t, \n and \r printable? (#4014)

This comment has been minimized.

@daurnimator

daurnimator Sep 1, 2020
Author Collaborator

For purposes of a debug print: I don't think they should be considered printable:

  • its hard to visually tell the difference between a tab that is one space wide an a normal space character.
  • I imagine this would often be used for line based output, where escaping newlines is desired.
  • \r is unprintable
@andrewrk andrewrk merged commit fb3c5b8 into ziglang:master Sep 2, 2020
2 of 3 checks passed
2 of 3 checks passed
ziglang.zig #20200831.20 failed
Details
builds.sr.ht: freebsd.yml builds.sr.ht job completed successfully
Details
continuous-integration/drone/pr Build is passing
Details
@daurnimator daurnimator deleted the daurnimator:fmt-non-printable branch Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.