Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (36 sloc) 1.49 KB
use 5.14.1;
use charnames ':full';
binmode(STDOUT, 'encoding(utf-8)');
my $i = 0;
my %digit = map { $i++ => $_ }
qw(ZERO ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE);
my $wonk = $ARGV[0] || die "usage: wonk \$type 'string to bold-ify'\n";
my $str = $ARGV[1] || die "usage: wonk \$type 'string to bold-ify'\n";
my $type = $wonk eq 'bold' ? 'MATHEMATICAL BOLD'
: $wonk eq 'script' ? 'MATHEMATICAL BOLD SCRIPT'
: $wonk eq 'fraktur' ? 'MATHEMATICAL FRAKTUR'
: $wonk eq 'italic' ? 'MATHEMATICAL ITALIC'
: $wonk eq 'ss' ? 'MATHEMATICAL SANS-SERIF'
: $wonk eq 'sc' ? 'LATIN LETTER SMALL'
: $wonk eq 'ssb' ? 'MATHEMATICAL SANS-SERIF BOLD'
: $wonk eq 'ssi' ? 'MATHEMATICAL SANS-SERIF ITALIC'
: $wonk eq 'ssbi' ? 'MATHEMATICAL SANS-SERIF BOLD ITALIC'
: $wonk eq 'fw' ? 'FULLWIDTH LATIN'
: die "unknown type: $wonk";
# FULLWIDTH LATIN SMALL LETTER W
if ($wonk eq 'sc') {
$str =~ s<([a-z])><
my $name = $1 ge 'a' && $1 le 'z' ? "$type CAPITAL \U$1" : undef;
$name ? charnames::string_vianame($name) // $1 : $1;
>ge;
} else {
$str =~ s<([a-z0-9])><
my $name = $1 ge 'a' && $1 le 'z' ? "$type SMALL \U$1"
: $1 ge 'A' && $1 le 'Z' ? "$type CAPITAL $1"
: $1 ge '0' && $1 le '9' ? "MATHEMATICAL BOLD DIGIT $digit{$1}"
: undef;
$name =~ s/ (.)$/ LETTER $1/ if $wonk eq 'fw';
$name ? charnames::string_vianame($name) // $1 : $1;
>gei;
}
say $str;