You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
833 B
37 lines
833 B
3 years ago
|
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();
|
||
|
}
|
||
|
}
|