On Tue, Dec 18, 2001, Dan Kenigsberg wrote about "Re: Hebrew Under gbiff":
>   my $s = shift;
>   my @spl = split('\?', $s);
> 
>   return $s if ($#spl != 3 || $spl[0] ne '=');
> 
>   ($_, $charset, $enc, $str) =  @spl;
> 
>   #TODO: handle other encodings and charsets
>   return $s if $charset ne 'WINDOWS-1255' or $enc ne 'Q';

Why check specificially if $charset is WINDOWS-1255? windows-1255,
iso-8559-8(-i)?, and a few other things would probably be ok for
your purposes too. I simply chose not to check it at all. Q also can be
lowercase, by the way.

> 
>   $accum = "";
>   while ($str =~ s/\=(..)//) {$accum = $accum.chr(hex($1))}

You forgot to convert underscores (_) back to spaces. If I remember
correctly, this is specified in RFC 2047.

> P.S. Thanks to whomever taught me Perl. Any comment is welcome.

Hmm, I wonder who that was :)
Anyway, you're right that Perl is a little more suited for the job. As
soon as I realised I had to write a hextonum() function in AWK, I knew
it wasn't the right language for the job (but I didn't care - I can
write AWK at least twice as fast as I write Perl... An old dog *can* learn
new tricks, but he still knows the old tricks better...)

By the way, I bet there's already a Perl module on CPAN that does RFC 2047
conversions. Anybody care to check?

-- 
Nadav Har'El                        |     Wednesday, Dec 19 2001, 4 Tevet 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Despite the cost of living, have you
http://nadav.harel.org.il           |noticed how it remains so popular?

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to