1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +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:
Ben Wiederhake 2021-10-31 02:05:45 +02:00 committed by Andreas Kling
parent 866c9cc1a5
commit a5dda0b0c5

View file

@ -45,15 +45,16 @@ int main(int argc, char** argv)
out(" "); out(" ");
} }
out(" "); out(" |");
for (size_t i = 0; i < 16; ++i) { for (size_t i = 0; i < line.size(); ++i) {
if (i < line.size() && isprint(line[i])) if (isprint(line[i]))
putchar(line[i]); putchar(line[i]);
else else
putchar(' '); putchar('.');
} }
putchar('|');
putchar('\n'); putchar('\n');
}; };