On Tue, Dec 18, 2001, Tzafrir Cohen wrote about "Re: Hebrew Under gbiff":
> On Wed, 12 Dec 2001, Herouth Maoz wrote:
> 
> > On 2001 December? 12 ,Wednesday 12:18, Eli Marmor wrote:
> > > Aharon Schkolnik wrote:
> > ..
> > > > =?WINDOWS-1255?Q?=E0=E4=F8
> > > >
> > > > Does anyone know why this is, and if there is anything I can do
> > > > about it ?
> > ..
> Where can I find such convertor already written?

Here's a little something I wrote to convert such quoted-printable
headers (it doesn't support base64 yet). Note that it's in awk, and
rather ugly; hackers-il devotees could start an entire flamewar on
why awk sucks for this purpose and perl/python/algol would have been
better - please avoid such arguments, and instead just provide better
(and tested) code - if you have it.

function hextonum(c){
        c=toupper(c)
        if(c=="A"){ return 10;
        } else if(c=="B"){ return 11;
        } else if(c=="C"){ return 12;
        } else if(c=="D"){ return 13;
        } else if(c=="E"){ return 14;
        } else if(c=="F"){ return 15;
        } else { return c; }
}
function tostring(s   ,a,i,n,b1,b2){
        # convert header possibly encoded like RFC 2047 to string we can
        # use to send an SMS
        if(s !~ /^=\?/ || s !~ /\?=$/ || split(s,a,"\?")!=5){
                return s;
        }
        if(a[3]=="q" || a[3]=="Q"){
                s="";
                n=length(a[4])
                for(i=1;i<=n;i++){
                        b=substr(a[4],i,1);
                        if(b=="_"){
                                s= s " "
                        } else if(b=="="){
                                b1=substr(a[4],i+1,1);
                                b2=substr(a[4],i+2,1);
                                i+=2
                                s= s sprintf("%c", hextonum(b1)*16+hextonum(b2))
                        } else {
                                s= s b
                        }
                }
                return s;
        }
        # TODO: handle B (base64) encoding
        # give up, I dont know what to do.
        return s;
}

-- 
Nadav Har'El                        |       Tuesday, Dec 18 2001, 3 Tevet 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Take my advice, I don't use it anyway.
http://nadav.harel.org.il           |

=================================================================
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