Created
April 2, 2015 15:28
-
-
Save grifferz/71ddb40652f5bea14290 to your computer and use it in GitHub Desktop.
Convert text to unicode bold math chars etc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
use open qw/:std :utf8/; | |
use constant OFFSET => 119737; | |
my $string = <STDIN>; | |
print str_to_bold($string); | |
exit 0; | |
sub str_to_bold { | |
my ($string) = @_; | |
my $bold; | |
foreach my $char (split(//, $string)) { | |
my $cp = ord($char); | |
my $offset = do { | |
if ($cp > 64 and $cp < 91) { OFFSET + 6} | |
else { OFFSET } | |
}; | |
if ($cp < 97 or $cp > 122) { | |
$bold .= $char; | |
} else { | |
$bold .= chr($cp + $offset); | |
} | |
} | |
return $bold; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment