我已经编写了一个Perl程序,在Perl中自动生成一系列Unicode字符。
#!/bin/perl -w
use strict;
use open qw/:std :encoding(UTF-8)/;
my ($beg, $end, $start, $finish, @chars);
print "Enter the beginning Unicode value of your Language's script: ";
chomp( $beg = <> );
print "Enter the last Unicode value of your Language's script: ";
chomp( $end = <> );
$beg =~ s/U\+(.*)/$1/;
$end =~ s/U\+(.*)/$1/;
$start = hex($beg);
$finish = hex($end);
@chars = ( $start .. $finish );
foreach (@chars) {
my $char = chr($_);
next unless ($char);
print "$char\n";
}
在使用值为
U+0B80
和U+0BFF
运行此脚本时,我的输出是:
所有这些盒子字符都是Unicode块中保留的空格。 ஂ ஃ அ ஆ இ ஈ உ ஊ எ ஏ ஐ ஒ ஓ ஔ க ங ச ஜ ஞ ட ண த ந ன ப ம ய ர ற ல ள ழ வ ஶ ஷ ஸ ஹ ா ி ீ ு ூ ெ ே ை ொ ோ ௌ ் ௐ ௗ ௦ ௧ ௨ ௩ ௪ ௫ ௬ ௭ ௮ ௯ ௰ ௱ ௲ ௳ ௴ ௵ ௶ ௷ ௸ ௹ ௺
我想删除所有这样的保留空格。有没有一种方法在perl中执行此操作?
代码行
next unless($char)
似乎行不通,因为即使预留空间似乎也有一个值(盒子字符)。
use charnames ();
。 - ysth