Created
March 16, 2019 04:52
-
-
Save mwgamera/5802a2bba2daa8130c0dec4e77c4b595 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Visual hex dump using CP437-like graphics. | |
# Only few fonts can handle that, but it's better than |........|. | |
# klg, Jul 2015; Jan 2018 | |
use strict; | |
use utf8; | |
use open ':std', ( | |
IN => ':bytes', | |
OUT => ':locale' | |
); | |
use constant CP437 => q< | |
☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ | |
!"#$%&'()*+,-./0123456789:;<=>? | |
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ | |
`abcdefghijklmnopqrstuvwxyz{|}~⌂ | |
ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒ | |
áíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ | |
└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ | |
αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ | |
> =~ s:[\r\n]::gr; | |
die unless 256 == length CP437; | |
my @G = split '', CP437; | |
my $addr = 0; | |
my $cnul = 0; | |
my $prev = ''; | |
local $/ = \16; | |
while (<<>>) { | |
if ($_ eq $prev) { | |
print "*\n" unless $cnul++; | |
} else { | |
$cnul = 0; | |
my $H = join(' ', | |
map { join' ', map {sprintf'%02x',ord} split'' } unpack '(a8)2'); | |
my $C = join '', map $G[$_], unpack 'C*'; | |
printf "%08x %-48s │%s│\n", $addr, $H, $C; | |
} | |
$prev = $_; | |
$addr += length; | |
} | |
printf "%08x\n", $addr; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment