Hex dump: Difference between revisions
Content deleted Content added
m →{{header|Phix}}: spacing tweak |
|||
Line 253: | Line 253: | ||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">lines</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">split_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">start</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">..</span><span style="color: #000000;">finish</span><span style="color: #0000FF;">],</span><span style="color: #000000;">ll</span><span style="color: #0000FF;">)</span> |
<span style="color: #004080;">sequence</span> <span style="color: #000000;">lines</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">split_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">start</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">..</span><span style="color: #000000;">finish</span><span style="color: #0000FF;">],</span><span style="color: #000000;">ll</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #008080;">for</span> <span style="color: #000000;">l</span> <span style="color: #008080;">in</span> <span style="color: #000000;">lines</span> <span style="color: #008080;">do</span> |
<span style="color: #008080;">for</span> <span style="color: #000000;">l</span> <span style="color: #008080;">in</span> <span style="color: #000000;">lines</span> <span style="color: #008080;">do</span> |
||
<span style="color: #004080;">string</span> <span style="color: #000000;">hb</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">ascii</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span> |
<span style="color: #004080;">string</span> <span style="color: #000000;">hb</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">" "</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">ascii</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">""</span> |
||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">,</span><span style="color: #000000;">b</span> <span style="color: #008080;">in</span> <span style="color: #000000;">l</span> <span style="color: #008080;">do</span> |
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">,</span><span style="color: #000000;">b</span> <span style="color: #008080;">in</span> <span style="color: #000000;">l</span> <span style="color: #008080;">do</span> |
||
<span style="color: #000000;">hb</span> <span style="color: #0000FF;">&=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hbfmt</span><span style="color: #0000FF;">,</span><span style="color: #000000;">b</span><span style="color: #0000FF;">)</span> |
<span style="color: #000000;">hb</span> <span style="color: #0000FF;">&=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hbfmt</span><span style="color: #0000FF;">,</span><span style="color: #000000;">b</span><span style="color: #0000FF;">)</span> |
||
<span style="color: #008080;">if</span> <span style="color: #000000;">b</span><span style="color: #0000FF;"><</span><span style="color: #008000;">' '</span> <span style="color: #008080;">or</span> <span style="color: #000000;">b</span><span style="color: #0000FF;">></span><span style="color: #008000;">'~'</span> <span style="color: #008080;">then</span> <span style="color: #000000;">b</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">'.'</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
<span style="color: #008080;">if</span> <span style="color: #000000;">b</span><span style="color: #0000FF;"><</span><span style="color: #008000;">' '</span> <span style="color: #008080;">or</span> <span style="color: #000000;">b</span><span style="color: #0000FF;">></span><span style="color: #008000;">'~'</span> <span style="color: #008080;">then</span> <span style="color: #000000;">b</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">'.'</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
||
<span style="color: #000000;">ascii</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">b</span> |
<span style="color: #000000;">ascii</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">b</span> |
||
<span style="color: #008080;">if</span> |
<span style="color: #008080;">if</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">8</span> <span style="color: #008080;">then</span> <span style="color: #000000;">hb</span> <span style="color: #0000FF;">&=</span> <span style="color: #008000;">' '</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span> |
||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
||
<span style="color: #000000;">hb</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">pad_tail</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hb</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bHex</span><span style="color: #0000FF;">?</span><span style="color: #000000;"> |
<span style="color: #000000;">hb</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">pad_tail</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hb</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">bHex</span><span style="color: #0000FF;">?</span><span style="color: #000000;">50</span><span style="color: #0000FF;">:</span><span style="color: #000000;">55</span><span style="color: #0000FF;">))</span> |
||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lnfmt</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">start</span><span style="color: #0000FF;">,</span><span style="color: #000000;">hb</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ascii</span><span style="color: #0000FF;">})</span> |
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lnfmt</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">start</span><span style="color: #0000FF;">,</span><span style="color: #000000;">hb</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ascii</span><span style="color: #0000FF;">})</span> |
||
<span style="color: #000000;">start</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">l</span><span style="color: #0000FF;">)</span> |
<span style="color: #000000;">start</span> <span style="color: #0000FF;">+=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">l</span><span style="color: #0000FF;">)</span> |
||
Line 277: | Line 277: | ||
<pre> |
<pre> |
||
Hexadecimal: |
Hexadecimal: |
||
00000000 FF FE 52 00 6F 00 73 00 65 00 74 00 74 00 61 00 |
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 20 00 43 00 6F 00 64 00 65 00 20 00 69 00 73 00 |
00000010 20 00 43 00 6F 00 64 00 65 00 20 00 69 00 73 00 | .C.o.d.e. .i.s.| |
||
00000020 20 00 61 00 20 00 70 00 72 00 6F 00 67 00 72 00 |
00000020 20 00 61 00 20 00 70 00 72 00 6F 00 67 00 72 00 | .a. .p.r.o.g.r.| |
||
00000030 61 00 6D 00 6D 00 69 00 6E 00 67 00 20 00 63 00 |
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 |
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 |
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 |
00000060 20 00 3D D8 00 DE 2E 00 | .=..... | |
||
00000068 |
00000068 |
||
Binary: |
Binary: |
||
00000000 11111111 11111110 01010010 00000000 01101111 00000000 |..R.o.| |
00000000 11111111 11111110 01010010 00000000 01101111 00000000 |..R.o.| |
||
00000006 01110011 00000000 01100101 00000000 01110100 00000000 |s.e.t.| |
00000006 01110011 00000000 01100101 00000000 01110100 00000000 |s.e.t.| |
||
0000000C 01110100 00000000 01100001 00000000 00100000 00000000 |t.a. .| |
0000000C 01110100 00000000 01100001 00000000 00100000 00000000 |t.a. .| |
||
00000012 01000011 00000000 01101111 00000000 01100100 00000000 |C.o.d.| |
00000012 01000011 00000000 01101111 00000000 01100100 00000000 |C.o.d.| |
||
00000018 01100101 00000000 00100000 00000000 01101001 00000000 |e. .i.| |
00000018 01100101 00000000 00100000 00000000 01101001 00000000 |e. .i.| |
||
0000001E 01110011 00000000 00100000 00000000 01100001 00000000 |s. .a.| |
0000001E 01110011 00000000 00100000 00000000 01100001 00000000 |s. .a.| |
||
00000024 00100000 00000000 01110000 00000000 01110010 00000000 | .p.r.| |
00000024 00100000 00000000 01110000 00000000 01110010 00000000 | .p.r.| |
||
0000002A 01101111 00000000 01100111 00000000 01110010 00000000 |o.g.r.| |
0000002A 01101111 00000000 01100111 00000000 01110010 00000000 |o.g.r.| |
||
00000030 01100001 00000000 01101101 00000000 01101101 00000000 |a.m.m.| |
00000030 01100001 00000000 01101101 00000000 01101101 00000000 |a.m.m.| |
||
00000036 01101001 00000000 01101110 00000000 01100111 00000000 |i.n.g.| |
00000036 01101001 00000000 01101110 00000000 01100111 00000000 |i.n.g.| |
||
0000003C 00100000 00000000 01100011 00000000 01101000 00000000 | .c.h.| |
0000003C 00100000 00000000 01100011 00000000 01101000 00000000 | .c.h.| |
||
00000042 01110010 00000000 01100101 00000000 01110011 00000000 |r.e.s.| |
00000042 01110010 00000000 01100101 00000000 01110011 00000000 |r.e.s.| |
||
00000048 01110100 00000000 01101111 00000000 01101101 00000000 |t.o.m.| |
00000048 01110100 00000000 01101111 00000000 01101101 00000000 |t.o.m.| |
||
0000004E 01100001 00000000 01110100 00000000 01101000 00000000 |a.t.h.| |
0000004E 01100001 00000000 01110100 00000000 01101000 00000000 |a.t.h.| |
||
00000054 01111001 00000000 00100000 00000000 01110011 00000000 |y. .s.| |
00000054 01111001 00000000 00100000 00000000 01110011 00000000 |y. .s.| |
||
0000005A 01101001 00000000 01110100 00000000 01100101 00000000 |i.t.e.| |
0000005A 01101001 00000000 01110100 00000000 01100101 00000000 |i.t.e.| |
||
00000060 00100000 00000000 00111101 11011000 00000000 11011110 | .=...| |
00000060 00100000 00000000 00111101 11011000 00000000 11011110 | .=...| |
||
00000066 00101110 00000000 |.. | |
00000066 00101110 00000000 |.. | |
||
00000068 |
00000068 |
||
</pre> |
</pre> |
||
=={{header|Python}}== |
=={{header|Python}}== |
||
<syntaxhighlight lang="python"> |
<syntaxhighlight lang="python"> |