Perl 6 and print columns
Does Perl 6 have something equivalent to the Unicode::GCString's columns
method?
Perl 5 example:
#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.0;
use utf8;
use open qw( :std :utf8 );
use Unicode::GCString;
my $s = '合'; # U+5408
say length $s; # 1
my $gcs = Unicode::GCString->new( $s );
say $gcs->columns; # 2
Perl6 has builtin Unicode support, with native Uni and NFC/NFD/NFKC/NFKD normalized types.
What I vaguely understand is, that the Unicode::GCString::columns method determines eastasian language linebreaking support. 合 is composed of 2 "syllables" (they call it "grapheme clusters") on top of each other, thus 2 columns.
That being said, perl6 internally (on the MoarVM level) has access to the unicode database where the linebreaking properties are stored, but to my knowledge there's currently no module, like Unicode::UCD available to make the East_Asian_Width properties available for something like a Unicode::GCString.
On the other side, converting Unicode::LineBreak to perl6 looks easy enough, accessing the sombok library via NativeCall.
链接地址: http://www.djcxy.com/p/86438.html上一篇: 如何在RxJava中执行递归Observable调用?
下一篇: Perl 6和打印列