# email中的主题如果包含非ascii的字符,一般会转化为一种特殊的格式。
# =?gb2312?B?uaTX98fpv/Y=?= 和 "=?gb2312?B?uaTX98fpv/Y=?=" 将返回 工作情况 这几个字
# 未用这种格式的将原样返回
#!/usr/bin/perl
use MIME::Base64;
use MIME::QuotedPrint;
use Text::Iconv;
sub get_gb2312#返回gb2312的主题
{
my ($subject) = @_;
my $subject_src;
if( $subject =~ /\=\?([^\s\(\)\<\>\@\,\:\;\"\/\?\.\=]+)\?([bBQq])\?([^\s\?]+)\?\=/ )
{
if( $2 eq "q" || $2 eq "Q" )
{
$subject_src = decode_qp( $3 );
}
elsif( $2 eq "b" || $2 eq "B" )
{
$subject_src = decode_base64( $3 );
}
if( !($1 =~ /^gb2312$/i) )
{
my $converter2gb2312 = Text::Iconv->new( $1, "gb2312" );
$subject_src = $converter2gb2312->convert($subject_src);
}
if( $subject_src ne ") { $subject = $subject_src ; } } return $subject; }
|
阅读(1969) | 评论(0) | 转发(0) |