1 #upsidedown.pl: display a string in pseudo-upsidedown utf-8 characters
3 # Licensing: Artistic License
4 # Version: v0.1 (20080425)
6 # taken from http://www.xs4all.nl/~johnpc/uniud/uniud-0.14.tar.gz
8 # NOTICE: This source contains UTF-8 unicode characters, but only in the
9 # comments. You can safely remove them if your editor barfs on them.
14 use Getopt::Long qw(:config nopermute bundling auto_help);
16 use vars qw($VERSION);
22 #die "huh?" unless ${^UNICODE} == 127; # force -CSDAL
26 '!' => "\x{00a1}", # ¡
27 '"' => "\x{201e}", # „
31 '&' => "\x{214b}", # ⅋
32 "'" => "\x{0375}", # ͵
37 ',' => "\x{2018}", # ‘
39 '.' => "\x{02d9}", # ˙
42 '1' => "\x{002c}\x{20d3}", # ,⃓ can be improved
43 '2' => "\x{10f7}", # ჷ
44 '3' => "\x{03b5}", # ε
45 '4' => "\x{21c1}\x{20d3}", # ⇁⃓ can be improved
46 '5' => "\x{1515}", # ᔕ or maybe just "S"
48 '7' => "\x{005f}\x{0338}", # _̸
52 ';' => "\x{22c5}\x{0315}", # ⋅̕ sloppy, should be improved
56 '?' => "\x{00bf}", # ¿
57 '@' => '@', # can be improved
58 'A' => "\x{13cc}", # Ꮜ
59 'B' => "\x{03f4}", # ϴ can be improved
60 'C' => "\x{0186}", # Ɔ
61 'D' => 'p', # should be an uppercase D!!
62 'E' => "\x{018e}", # Ǝ
63 'F' => "\x{2132}", # Ⅎ
64 'G' => "\x{2141}", # ⅁
67 'J' => "\x{017f}\x{0332}", # ſ̲
68 'K' => "\x{029e}", # ʞ should be an uppercase K!!
69 'L' => "\x{2142}", # ⅂
70 'M' => "\x{019c}", # Ɯ or maybe just "W"
73 'P' => 'd', # should be uppercase P
74 'Q' => "\x{053e}", # Ծ can be improved
75 'R' => "\x{0222}", # Ȣ can be improved
77 'T' => "\x{22a5}", # ⊥
78 'U' => "\x{144e}", # ᑎ
79 'V' => "\x{039b}", # Λ
82 'Y' => "\x{2144}", # ⅄
87 '^' => "\x{203f}", # ‿
88 '_' => "\x{203e}", # ‾
89 '`' => "\x{0020}\x{0316}", # ̖
90 'a' => "\x{0250}", # ɐ
92 'c' => "\x{0254}", # ɔ
94 'e' => "\x{01dd}", # ǝ
95 'f' => "\x{025f}", # ɟ
96 'g' => "\x{0253}", # ɓ
97 'h' => "\x{0265}", # ɥ
98 'i' => "\x{0131}\x{0323}", # ı̣
99 'j' => "\x{017f}\x{0323}", # ſ̣
100 'k' => "\x{029e}", # ʞ
101 'l' => "\x{01ae}", # Ʈ can be improved
102 'm' => "\x{026f}", # ɯ
107 'r' => "\x{0279}", # ɹ
109 't' => "\x{0287}", # ʇ
111 'v' => "\x{028c}", # ʌ
112 'w' => "\x{028d}", # ʍ
114 'y' => "\x{028e}", # ʎ
119 '~' => "\x{223c}", # ∼
121 my $missing = "\x{fffd}"; # � replacement character
123 # turnedstr - handle turning one string
129 # add reverse mappings
130 foreach my $up (keys %updown) {
131 $updown{$updown{$up}} = $up if ! exists $updown{$updown{$up}};
134 for my $char ( $str =~ /(\X)/g ) {
135 #print STDERR "str=\"$str\" char=\"$char\"\n";
136 if ( exists $updown{$char} ) {
137 my $t = $updown{$char};
138 $t = $missing if !length($t);
139 $turned = $t . $turned;
142 elsif ( $char eq "\t" ) {
143 my $tablen = 8 - $tlength % 8;
144 $turned = " " x $tablen . $turned;
147 elsif ( ord($char) >= 32 ) {
148 ### other chars copied literally
149 $turned = $char . $turned;
159 &::performStrictReply( turnedstr( $message ) );
162 #binmode(STDERR, "encoding(UTF-8)");
163 #print STDERR turnedstr("upsidedown ɟǝpɔqɐabcdef") . "\n";
166 # vim:ts=4:sw=4:expandtab:tw=80