-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Printing whitespace characters with {c} #4014
Comments
I labeled it as a bug, but then I checked the behavior of libc |
cc @Vexu, curious about your thoughts on this. |
I think all whitespace with escape sequences ( |
Hmm, how about this proposal: Change \t, \n, \r to return |
I can't find any specification on what the |
@thejoshwolfe From rummaging around the Go source and package documentation,
|
%c in C outputs the "raw byte" with no checks on whether it's printable or not (which is why you can do terminal escapes with printf). \t, \n, and \r are considered control characters instead of printable characters because instead of being one character, they do "magic" stuff with terminals usually--\t advances to the next tab stop, \n moves to the next line, \r moves to the beginning of the line. I'd suggest adding some "raw string" and "raw character" formatting directives or remove the escaping behaviour altogether. |
21bc335 changed the behavior of the
{c}
formatting directive:The effect of this is:
This is because
).
std.ascii.isPrint
returns false on whitespace other than 0x20 (This behavior does not match the behavior of the
%c
directive in C, Go, and other languages. Is this departure intentional? If so, what's the proper way to print a string character-by-character?The text was updated successfully, but these errors were encountered: