有人能告诉我为什么这个片段失败并出现以下错误吗?我也试过
utf8::downgrade()
打电话之前from_to()
没有成功。使用 Perl 5.14.2。
有任何想法吗??
代码:
use Encode qw(from_to);
use HTML::Entities;
$s = "มหัศ";
$foo = decode_entities($s);
print "is foo UTF8? ", utf8::is_utf8($foo), "\n";
from_to($foo, 'UTF-8', 'UTF-16');
输出:
is foo UTF8? 1
Cannot decode string with wide characters at /usr/lib/perl/5.14/Encode.pm line 194.