perl-unicode

Re: How to convert base64 string to utf-8

2004-02-04 05:30:05
John Delacour wrote:
skiped

use Encode;
use MIME::Base64;
use MIME::QuotedPrint;
my $string;
$_ = <<_;
=?utf-8?B?15TXoNeUINee16nXlNeZINeR16LXkdeo15nXqi4=?=
_
/=\?(.+)\?([BQ])\?(.+)\?=/;
my ( $charset, $encoding, $_7bit ) = ( $1, $2, $3 );

if ( $encoding eq 'B' ) { $string = decode_base64 $_7bit }
if ( $encoding eq 'Q' ) { $string = decode_qp $_7bit }

Encode::from_to( $string, $charset, "utf8" ) or die $!;
print $string;

Thank you, I'll try it.