perl - Perl Encode.pm无法解码具有宽字符的字符串

标签 perl unicode utf-8

我正在运行一个使用/opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level/Encode.pm的perl应用程序

并发出错误


无法在/opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level/Encode.pm第174行解码带有宽字符的字符串。


Encode.pm的第174行读取

sub decode($$;$) {
    my ( $name, $octets, $check ) = @_;
    return undef unless defined $octets;
    $octets .= '' if ref $octets;
    $check ||= 0;
    my $enc = find_encoding($name);
    unless ( defined $enc ) {
        require Carp;
        Carp::croak("Unknown encoding '$name'");
    }
    my $string = $enc->decode( $octets, $check );  # line 174
    $_[1] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() );
    return $string;
}


任何解决方法?

最佳答案

我有一个类似的问题。
$enc->decode( $octets, $check );需要八位字节。

所以放在Encode::_utf8_off($octets)之前。它对我有用。

关于perl - Perl Encode.pm无法解码具有宽字符的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12994100/

相关文章:

perl 如何模拟线程行为

perl - 通过 $_ 打开命令行上提供的文件名是否存在问题?

bash - 如何从 bash 中的变量中删除文字字符串 "\n"(不是换行符)?

xml - 只要 XHTML 实体编码包含在 CDATA 标记内,它们在 XML 文档中是否有效?

html - UTF-8 编码仅适用于 index.html?

linux - 如何自动化 HTML 到 PDF 的转换?

python - Python 中的希伯来语 unicode

http - 请帮助我跟踪如何在每一步处理字符集

php - 如何在 mysql 或 php 中将 'u00e9' 转换为 utf8 字符?

php - file_get_contents() 分解 UTF-8 字符