http://www.perlmonks.org?node_id=938640


in reply to MIME::Parser::Filer and filenames in Simplified Chinese

Can't help with MIME::Parser, but you can decode name yourself:

use 5.010; use strict; use warnings; use open qw(:utf8 :std); use Encode::MIME::EncWords; use Encode qw/encode decode/; my $fname = '=?gb2312?B?MzYw0MLOxbzgsuItMTItMDEtQ2hpIFNpbXAudHh0?='; say decode('MIME-EncWords', $fname);

Replies are listed 'Best First'.
Re^2: MIME::Parser::Filer and filenames in Simplified Chinese
by uxbod (Initiate) on Nov 21, 2011 at 16:21 UTC

    Thanks Zwon. I have managed to get a little further but now I have an issue between Simplified and Traditional Chinese.

    The MIME encoding for the following file name

    =?gb2312?B?MzYw0MLOxbzgsuItMTItMDEtQ2hpIFNpbXAudHh0?=

    should decode to:

    DPM2007exchange電郵與郵箱修復.zip

    but when I try and decode that name in Perl it comes out as:

    DPM2007exchange���]�c�]箱修��.zip

    I have installed the Encode::HanExtra module but even with that it is still not showing correctly. Am I missing some other type of module ?

      comes out as where? Showing correctly where?

      Does the program produce the correct bytes?

        Here is some test code I am using to try and resolve the problem
        #!/usr/bin/perl use Encode; use Encode::CN; use Encode::TW; use MIME::EncWords qw ( /decode_mimewords/); binmode STDOUT, ":utf8"; my $text = "=?gb2312?B?RFBNMjAwN2V4Y2hhbmdl64rgXcVj4F3P5NDej80uemlw?=" +; my(@chunks) = decode_mimewords($text); for my $pair (@chunks) { my($data,$encoding) = @$pair; my $filename = Encode::decode($encoding,$data); print $filename . "\n"; }