mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +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
1 changed files with 5 additions and 4 deletions
|
@ -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');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue