[Israel.pm] decoding windows-1255

Oded Arbel oded-linux at typo.co.il
Thu Mar 23 07:56:46 PST 2006


On Thursday, 23 בMarch 2006 17:25, Gabor Szabo wrote:
> In an e-mail I get this subject line:
>
> Subject:
>
> =?windows-1255?B?UmVhZDog7vHu6+ntIOfj+entIOz65Ozp6+kg4eno5ecg5+np7SBb
>8enu?= =?windows-1255?B?5evp7yAxMDVd?=

It means that the subject line is encoded as base64 ("?B?") and the 
character set is cp1255 ("?windows-1255?"). 

This small piece of code might give you something useful:
 echo "$ENCODED_SUBJECT" | perl -MMIME::Base64 -nle 'while (m|=\?
([^\?]+)\?B\?([^\?]+)\?|g) { $x = decode_base64($2); print `echo "$x" | 
iconv -f $1 -t utf-8;`}'

Assuming that your terminal uses utf-8 encoding.
I'm sure other people can figure a better way to handle it.
For reference, read RFC 1522.

-- 
Oded

::..
Money can't buy love, but it sure gets you a great bargaining position
	-- Murphy's Love Laws n°6




More information about the Perl mailing list