Skip to content

Instantly share code, notes, and snippets.

@grifferz
Created April 2, 2015 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grifferz/71ddb40652f5bea14290 to your computer and use it in GitHub Desktop.
Save grifferz/71ddb40652f5bea14290 to your computer and use it in GitHub Desktop.
Convert text to unicode bold math chars etc
#!/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