Hex dump: Difference between revisions
Content deleted Content added
julia example |
m →{{header|Julia}}: no extended ascii printing |
||
Line 252: | Line 252: | ||
vstr *= " "^(base!=2) * join(values[begin+halflen:end]) |
vstr *= " "^(base!=2) * join(values[begin+halflen:end]) |
||
end |
end |
||
cstr = prod(map(n -> isprint(Char(n)) ? Char(n) : '.', chunk)) |
cstr = prod(map(n -> n < 128 && isprint(Char(n)) ? Char(n) : '.', chunk)) |
||
println(string(pos, base= 16, pad = 8) * " " * rpad(vstr, vlen) * "|" * cstr * "|") |
println(string(pos, base= 16, pad = 8) * " " * rpad(vstr, vlen) * "|" * cstr * "|") |
||
pos += fullchunksize |
pos += fullchunksize |
||
Line 261: | Line 261: | ||
decdump(data; offset = 0, len = -1) = baseddump(data, 10; offset, len) |
decdump(data; offset = 0, len = -1) = baseddump(data, 10; offset, len) |
||
const |
const tstr = b"\xff\xfeRosetta Code is a programming chrestomathy site 😀." |
||
const utf16 = vcat(b"\xff\xfe", reinterpret(UInt8, transcode(UInt16, tstr[begin+2:end]))) |
|||
print("hexdump of "), display(String( |
print("hexdump of 16-bit "), display(String(tstr)) |
||
hexdump( |
hexdump(utf16) |
||
print("\nxxd of "), display(String( |
print("\nxxd of 16-bit "), display(String(tstr)) |
||
xxd( |
xxd(utf16) |
||
print("\ndecdump of "), display(String( |
print("\ndecdump of 16-bit"), display(String(tstr)) |
||
decdump( |
decdump(utf16) |
||
</syntaxhighlight>{{out}} |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
hexdump of " |
hexdump of 16-bit "\xff\xfeRosetta Code is a programming chrestomathy site 😀." |
||
00000000 |
00000000 ff fe 52 00 6f 00 73 00 65 00 74 00 74 00 61 00 |..R.o.s.e.t.t.a.| |
||
00000010 |
00000010 20 00 43 00 6f 00 64 00 65 00 20 00 69 00 73 00 | .C.o.d.e. .i.s.| |
||
00000020 |
00000020 20 00 61 00 20 00 70 00 72 00 6f 00 67 00 72 00 | .a. .p.r.o.g.r.| |
||
00000030 |
00000030 61 00 6d 00 6d 00 69 00 6e 00 67 00 20 00 63 00 |a.m.m.i.n.g. .c.| |
||
00000040 68 00 72 00 65 00 73 00 74 00 6f 00 6d 00 61 00 |h.r.e.s.t.o.m.a.| |
|||
00000050 74 00 68 00 79 00 20 00 73 00 69 00 74 00 65 00 |t.h.y. .s.i.t.e.| |
|||
00000060 20 00 3d d8 00 de 2e 00 | .=.....| |
|||
xxd of " |
xxd of 16-bit "\xff\xfeRosetta Code is a programming chrestomathy site 😀." |
||
00000000 |
00000000 11111111 11111110 01010010 00000000 01101111 00000000 |..R.o.| |
||
00000006 |
00000006 01110011 00000000 01100101 00000000 01110100 00000000 |s.e.t.| |
||
0000000c |
0000000c 01110100 00000000 01100001 00000000 00100000 00000000 |t.a. .| |
||
00000012 |
00000012 01000011 00000000 01101111 00000000 01100100 00000000 |C.o.d.| |
||
00000018 |
00000018 01100101 00000000 00100000 00000000 01101001 00000000 |e. .i.| |
||
0000001e |
0000001e 01110011 00000000 00100000 00000000 01100001 00000000 |s. .a.| |
||
00000024 |
00000024 00100000 00000000 01110000 00000000 01110010 00000000 | .p.r.| |
||
0000002a |
0000002a 01101111 00000000 01100111 00000000 01110010 00000000 |o.g.r.| |
||
00000030 01100001 00000000 01101101 00000000 01101101 00000000 |a.m.m.| |
|||
00000030 11110000 10011111 10011000 10000000 00101110 |ð....| |
|||
00000036 01101001 00000000 01101110 00000000 01100111 00000000 |i.n.g.| |
|||
0000003c 00100000 00000000 01100011 00000000 01101000 00000000 | .c.h.| |
|||
00000042 01110010 00000000 01100101 00000000 01110011 00000000 |r.e.s.| |
|||
00000048 01110100 00000000 01101111 00000000 01101101 00000000 |t.o.m.| |
|||
0000004e 01100001 00000000 01110100 00000000 01101000 00000000 |a.t.h.| |
|||
00000054 01111001 00000000 00100000 00000000 01110011 00000000 |y. .s.| |
|||
0000005a 01101001 00000000 01110100 00000000 01100101 00000000 |i.t.e.| |
|||
00000060 00100000 00000000 00111101 11011000 00000000 11011110 | .=...| |
|||
00000066 00101110 00000000 |..| |
|||
decdump of " |
decdump of 16-bit"\xff\xfeRosetta Code is a programming chrestomathy site 😀." |
||
00000000 |
00000000 255 254 082 000 111 000 115 000 101 000 |..R.o.s.e.| |
||
0000000a |
0000000a 116 000 116 000 097 000 032 000 067 000 |t.t.a. .C.| |
||
00000014 111 |
00000014 111 000 100 000 101 000 032 000 105 000 |o.d.e. .i.| |
||
0000001e |
0000001e 115 000 032 000 097 000 032 000 112 000 |s. .a. .p.| |
||
00000028 |
00000028 114 000 111 000 103 000 114 000 097 000 |r.o.g.r.a.| |
||
00000032 |
00000032 109 000 109 000 105 000 110 000 103 000 |m.m.i.n.g.| |
||
0000003c 032 000 099 000 104 000 114 000 101 000 | .c.h.r.e.| |
|||
00000046 115 000 116 000 111 000 109 000 097 000 |s.t.o.m.a.| |
|||
00000050 116 000 104 000 121 000 032 000 115 000 |t.h.y. .s.| |
|||
0000005a 105 000 116 000 101 000 032 000 061 216 |i.t.e. .=.| |
|||
00000064 000 222 046 000 |....| |
|||
</pre> |
</pre> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |