Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit dd900189032ece666c1f102ae995e16267bf74a9 created 5 years 14 days ago. By Werner Almesberger, bin/hi8: highlight 8-bit chars; -g for "grep" mode: show only lines with 8-bit | |
---|---|
1 | #!/usr/bin/perl |
2 | sub usage |
3 | { |
4 | print STDERR "usage: $0 [-g] [file ...]\n"; |
5 | exit(1); |
6 | } |
7 | |
8 | if ($ARGV[0] eq "-g") { |
9 | $grep = 1; |
10 | shift @ARGV; |
11 | } |
12 | &usage if $ARGV[0] =~ /^-/; |
13 | |
14 | while (<>) { |
15 | @c = unpack "C*"; |
16 | for (@c) { |
17 | if ($_ == 10) { |
18 | print "$s\n" if $found || !$grep; |
19 | $found = 0; |
20 | undef $s; |
21 | } elsif ($_ < 0x80) { |
22 | $s .= pack("c", $_); |
23 | } else { |
24 | $s .= sprintf("\e[7m%02x\e[0m", $_); |
25 | $found = 1; |
26 | } |
27 | } |
28 | } |
29 |
Branches:
master