【发布时间】:2012-06-08 17:01:55
【问题描述】:
我有 utf8 字节序列,需要将其修剪为 30 字节。这可能导致最后的序列不完整。我需要弄清楚如何删除不完整的序列。
例如
$b="\x{263a}\x{263b}\x{263c}";
my $sstr;
print STDERR "length in utf8 bytes =" . length(Encode::encode_utf8($b)) . "\n";
{
use bytes;
$sstr= substr($b,0,29);
}
#After this $sstr contains "\342\230\272\342"\0
# How to remove \342 from the end
【问题讨论】: