blob: 6fa7998a013adf5011a6759396eeace5ec49e1ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/env perl
#
use warnings;
use diagnostics;
use strict;
use utf8;
binmode(STDIN, ":encoding(UTF-8)");
binmode(STDOUT, ":encoding(UTF-8)");
binmode(STDERR, ":encoding(UTF-8)");
my $width = 12;
my $height = 22;
my $dblwidth = 2 * $width;
print "# Width: $width\n";
print "# Height: $height\n";
while (<>) {
if (/^STARTCHAR U\+([[:xdigit:]]{4,})/) {
print "$1:";
}
elsif (/^[[:digit:]]+ \|([ █]{$width})\|/u) {
my $bits = $1;
$bits =~ tr/ █/01/;
print unpack("H*", pack("B*", $bits . "0000")); # 12 bits + 0000
}
elsif (/^[[:digit:]]+ \|([ █]{$dblwidth})\|/u) {
my $bits = $1;
$bits =~ tr/ █/01/;
print unpack("H*", pack("B*", $bits)); # 24 bits
}
elsif (/^ENDCHAR$/) {
print "\n";
}
else {
print STDERR "unrecognized line: $_";
exit 1;
}
}
# vi: set tabstop=2 shiftwidth=2 expandtab fileformat=unix:
|