[your code here] HexViewer

Vladimir Panteleev via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 2 14:59:23 PDT 2017


On Wednesday, 2 August 2017 at 19:39:18 UTC, Andre Pany wrote:
> This application opens the file passed as argument and display 
> the content in hex and text format:

Good idea! But I think it needs more ranges:

void main(string[] args)
{
     import std.algorithm, std.format, std.stdio;
     enum cols = 16;
     args[1].File("rb").byChunk(16).map!(chunk =>
         format!"%(%02X %)%*s  %s"(
             chunk,
             3 * (cols - chunk.length), "",
             chunk.map!(c =>
                 c < 0x20 || c > 0x7E ? '.' : char(c))))
         .each!writeln;
}



More information about the Digitalmars-d mailing list