We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6025366 + 1404e48 commit 6476dd2Copy full SHA for 6476dd2
index.dd
@@ -123,6 +123,24 @@ void main()
123
}
124
----
125
)
126
+$(EXTRA_EXAMPLE_RUNNABLE Print hex dump,
127
+----
128
+void main()
129
+{
130
+ import std.algorithm, std.stdio, std.file;
131
+ enum cols = 16;
132
+ // Split file into 16-byte chunks per row
133
+ thisExePath.File("rb").byChunk(cols).each!(chunk =>
134
+ // Use range formatting to format the
135
+ // hexadecimal part and align the text part
136
+ writefln!"%(%02X %)%*s %s"(
137
+ chunk,
138
+ 3 * (cols - chunk.length), "", // Padding
139
+ chunk.map!(c => // Replace non-printable
140
+ c < 0x20 || c > 0x7E ? '.' : char(c))));
141
+}
142
143
+)
144
$(EXTRA_EXAMPLE Start a minimal web server,
145
146
#!/usr/bin/env dub
0 commit comments