decoding "quoted-printable"

Klaus Major klaus at major-k.de
Tue Jun 5 07:12:46 EDT 2007


Hi Mark,

> Klaus, this is a function from an old project that worked well  
> enough for its purpose...maybe good enough for your needs?
>
> function decodeQP pStr
>   put 0 into tc
>   repeat for each char c in pStr
>     if c is "=" then put 1 into tc
>     if tc = 0 then
>       put c after decodedStr
>     else
>       if c is not "=" then
>         put c into char tc of hexVal
>         add 1 to tc
>       end if
>       if tc = 3 then
>         put numToChar(baseConvert(hexVal,16,10)) after decodedStr
>         put 0 into tc
>       end if
>     end if
>   end repeat
>   return decodedStr
> end decodeQP

Found a little inconvenience in the script, it will also swallow all  
"=" & following 2 chars in the text,
even if they are not in "123456789ABCDEF"

Know what I mean?

I tried to check if the 2 characters AFTER a "=" are eventually  
hexadecimal with no succes.
I used this little function:

function ishex derchar
   if derchar is in "0123456789" OR (chartonum(derchar) > 62 AND  
chartonum(derchar) < 71) then
     return true
   else
     return false
   end if
end ishex

Am I missing something?

Any further hints are even more appreciated :-)

> Best,
>
> Mark

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de





More information about the use-livecode mailing list