admin管理员组文章数量:1123687
I guess I went down a unicode rabbithole, and I need help getting out. I was testing how to line up things with sprintf
and unicode strings, so I was kind of expecting this:
use Encode qw/decode encode/;
use utf8;
$\ = "\n"; $, = "\t";
open my $uni, "unicode_strings.txt";
my @in = map { chomp; $_ } <$uni>;
my @l = map {
my $decoded = utf8::is_utf8($input) ? $input : decode("UTF-8", $_);
[
sprintf ("%-32s", $decoded),
sprintf ("%02i", length($decoded)),
sprintf ("%02i", length($_)),
]
} @in;
print encode "UTF-8", $_ for map { join " | ", $_->@* } @l;
with this input:
normal
übung
schön
fähig
niño
crème brûlée
smörgåsbord
добрый день
本文标签:
perlsprintf and multicolumn Unicode charactersStack Overflow
版权声明:本文标题:perl - sprintf and multi-column Unicode characters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1736587394a1945030.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论