master
Ondřej Hruška 2 years ago
parent fc1dee1e3f
commit f08bfcd16b
  1. 36
      8to7.d

@ -0,0 +1,36 @@
module main;
import std.stdio;
import std.uni : isWhite;
import std.string : strip, empty;
import std.array;
import std.format.read : formattedRead;
void main() {
ubyte b;
while(!stdin.eof()) {
string line = strip(readln());
if (line.empty) { return; }
auto pieces = line.split!isWhite;
foreach (string p; pieces) {
if (1 == formattedRead(p, "%x", &b)) {
writef("%02x ", b & 0x7F);
}
}
write(" ");
foreach (string p; pieces) {
if (1 == formattedRead(p, "%x", &b)) {
b = b & 0x7F;
if (b < 32 || b >= 127) {
write(".");
} else {
writef("%s", cast(char)b);
}
}
}
writeln();
}
}
Loading…
Cancel
Save