Subject: | Math based on columns() seems correct but actual columns in use (using a monospace font) can be wrong |
If you run the attached script in a terminal that does utf8 correctly and has a good Monospaced Unicode font like Menlo you'll note that the 🤔line is too far right. It is as if it actually takes up 2 columns but it is reported as 1 column. May not matter but it is a 5 digit code point and the others are 4.
Thanks!
```
| I am ascii.......... |
| ‼ what!............. |
| ⁇ curious........... |
| ✏️ take note......... |
| 🤔 hmmm.............. |
$VAR1 = {
"\x{1f914} hmmm" => 6,
"\x{203c} what!" => 7,
'I am ascii' => 10,
"\x{2047} curious" => 9,
"\x{270f}\x{fe0f} take note" => 11
};
```
Subject: | unicode_col.pl |
use strict;
use warnings;
use Data::Dumper;
use Unicode::GCString;
binmode STDOUT, ":utf8";
my %strings;
my @strings = (
"I am ascii",
"â¼ what!",
"â curious",
"âï¸ take note",
"ð¤ hmmm"
);
for my $str (@strings) {
utf8::decode($str);
my $cols = Unicode::GCString->new($str)->columns;
$strings{$str} = $cols;
my $pad = "." x ( 20 - $cols );
print "| $str$pad |\n";
}
print Dumper( \%strings );