small fixes
[git2print.git] / banner.pl
blobafafba7850ded3b77e92d0dd7ed54c19e9688727
1 #!/usr/bin/env perl
3 # This software is part of the OSP dingbat suite.
5 use strict;
6 use File::Find;
8 # unicode support
9 use utf8;
10 use open ':encoding(utf8)';
11 binmode(STDOUT, ":utf8");
13 # yes, there's Unicode::UCD. this script is monadic...
14 my %symbols = (
15 currency_symbols => [0x20A0..0x20CF],
16 letterlike_symbols => [0x2100..0x214F],
17 number_forms => [0x2150..0x218F],
18 mathematical_operators => [0x2200..0x22FF],
19 supplemental_mathematical_operators => [0x2A00..0x2AFF],
20 miscellaneous_mathematical_symbols_a => [0x27C0..0x27EF],
21 miscellaneous_mathematical_symbols_b => [0x2980..0x29FF],
22 miscellaneous_symbols_and_arrows => [0x2B00..0x2BFF],
23 arrows => [0x2190..0x21FF],
24 control_pictures => [0x2400..0x243F],
25 miscellaneous_technical => [0x2300..0x23FF],
26 optical_character_recognition => [0x2440..0x245F],
27 geometric_shapes => [0x25A0..0x25FF],
28 miscellaneous_symbols => [0x2600..0x26FF],
29 dingbats => [0x2700..0x27BF],
30 yijing_hexagram_symbols => [0x4DC0..0x4DFF],
31 enclosed_alphanumerics => [0x2460..0x24FF],
32 enclosed_cjk_letters_and_months => [0x3200..0x32FF],
33 cjk_compatibility => [0x3300..0x33FF],
34 braille_patterns => [0x2800..0x28FF],
37 my @blocks = keys %symbols;
38 %symbols = &filter_empty(\%symbols);
39 my %secret_code = ();
41 my @slogans = ("no code aesthetics", "vatos locos", "write your own software, break your own software");
43 foreach (@slogans) {
44 my $slogan = `banner $_`;
45 $slogan = &string2secret($slogan);
46 my $filename = &string2secret("slogan");
47 open FILE, ">$filename";
48 print FILE $slogan;
49 close FILE;
52 sub filter_empty {
53 # this procedure filters out unassigned unicode code points
54 my %symbols = %{$_[0]};
55 while ( my ($key, $value) = each %symbols) {
56 my @remove_empty = ();
57 foreach (@{$value}) {
58 if (chr($_) =~ /\p{Assigned}/) {
59 push @remove_empty, $_;
62 $symbols{$key} = \@remove_empty;
64 %symbols;
67 sub string2secret {
68 my $temp;
69 foreach my $char (split //, $_[0]) {
70 if ($char =~ /\s/) {
71 $temp .= $char;
73 else {
74 my @random_block = @{$symbols{$blocks[int(rand(@blocks))]}};
75 $secret_code{$char} = chr($random_block[int(rand(@random_block))]);
76 $temp .= $secret_code{$char};
79 $temp;
82 # in one issue he used Dingbat as the font for what he considered a rather
83 # dull interview