aboutsummaryrefslogtreecommitdiff
path: root/fraktur.pl
blob: 817e409468dbcadf2431adfde244301e3081d09b (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
42
43
44
45
#!/usr/bin/perl -CIOESA -w

use utf8;

our $fu = "𝔄𝔅ℭ𝔇𝔈𝔉𝔊ℌℑ𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔ℜ𝔖𝔗𝔘𝔙𝔚𝔛𝔜ℨ";
our $fl = "𝔞𝔟𝔠𝔡𝔢𝔣𝔤𝔥𝔦𝔧𝔨𝔩𝔪𝔫𝔬𝔭𝔮𝔯𝔰𝔱𝔲𝔳𝔴𝔵𝔶𝔷";
our $fub = "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅";
our $flb = "𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟";

sub frakturize {
	my $text = shift;
	my $bold = shift || 0;
	my $out = "";
	my $c;

	for (split('', $text)) {
		if($_ ge 'a' && $_ le 'z') {
			$c = substr(($bold ? $flb : $fl), ord($_) - ord('a'), 1);
		} elsif($_ ge 'A' && $_ le 'Z') {
			$c = substr(($bold ? $fub : $fu), ord($_) - ord('A'), 1);
		} else {
			$c = $_;
		}
		$out .= $c;
	}

	return $out;
}

our $bold = 0;

if(@ARGV && ($ARGV[0] =~ /-b/)) {
	$bold = 1;
	shift;
}

if(@ARGV) {
	print frakturize($_, $bold) . " " for @ARGV;
	print "\n";
	exit 0;
}

while(<>) {
	print frakturize($_, $bold);
}