mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
hexdump: Make non-ASCII output easier to read
Enclose the ASCII-interpretation in pipes, show non-ASCII bytes as a dot, and fix the length of the last line. Note that this makes it more similar to the behavior of many other implementations.
This commit is contained in:
parent
866c9cc1a5
commit
a5dda0b0c5
|
@ -45,15 +45,16 @@ int main(int argc, char** argv)
|
|||
out(" ");
|
||||
}
|
||||
|
||||
out(" ");
|
||||
out(" |");
|
||||
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
if (i < line.size() && isprint(line[i]))
|
||||
for (size_t i = 0; i < line.size(); ++i) {
|
||||
if (isprint(line[i]))
|
||||
putchar(line[i]);
|
||||
else
|
||||
putchar(' ');
|
||||
putchar('.');
|
||||
}
|
||||
|
||||
putchar('|');
|
||||
putchar('\n');
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue