2

これらの Unicode 範囲では、 Unicode::GCStringcolumnsは印刷列の数を返しますが、Text mbswidth:: CharWidthは返しません。
異なるデータベースを使用するため、動作が異なるのですか?

#!/usr/bin/env perl
use warnings;
use strict;
use open qw(:std :utf8);
use Text::CharWidth qw(mbswidth);  # 0.04
use Unicode::GCString;             # 2012.10 

for my $hex ( 0x0378 .. 0xd7ff, 0xfa2e .. 0xfdcf, 0xfdfe .. 0xfff8 ) {
    my $chr = chr $hex;
    if ( mbswidth( $chr ) == -1 ) { # -1 invalid data
        my $gcs = Unicode::GCString->new( $chr );
        my $width = $gcs->columns;
        printf "%04x - %d  :  %s\n", $hex, $width, $chr;
    }
}
4

1 に答える 1