PowerBASIC Forums
  Source Code
  UUdecode - complete routine..

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   UUdecode - complete routine..
Borje Hagsten
Member
posted December 13, 2002 02:37 PM     Click Here to See the Profile for Borje Hagsten     Edit/Delete Message   Reply w/Quote

'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
' Purpose: UUdecode a given UUencoded text and return the result.
'
' Original code was not 100% correct, so have replaced it with code
' from Peter Redei. Thank you Peter! Your routine is much more correct.
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
FUNCTION uuDecode(strIn AS STRING) AS STRING
ON ERROR RESUME NEXT
DIM strLine AS STRING
DIM strDecoded AS STRING
DIM i AS LONG
DIM j AS LONG
DIM sOut AS STRING

IF LEFT$(strIn, 6) = "begin " THEN 'check if it is a encoded file
strIn = MID$(strIn, INSTR(1, strIn, $LF) + 1)
END IF
IF RIGHT$(strIn, 4) = "end" + $LF THEN 'check if "end" is available
strIn = LEFT$(strIn, LEN(strIn) - 7)
END IF
FOR j = 1 TO PARSECOUNT(strIn, $LF)
strLine = PARSE$(strIn, $LF, j)

strLine = MID$(strLine, 2)
REPLACE "`" WITH " " IN strLine
IF RIGHT$(strLine, 1) = CHR$(13) THEN strLine = LEFT$(strLine, LEN(strLine) - 1)
FOR i = 1 TO LEN(strLine) STEP 4
'now some decoding
strDecoded = strDecoded + CHR$((ASC(MID$(strLine, i, 1)) - 32) * 4 + _
(ASC(MID$(strLine, i + 1, 1)) - 32) \ 16)
strDecoded = strDecoded + CHR$((ASC(MID$(strLine, i + 1, 1)) MOD 16) * 16 + _
(ASC(MID$(strLine, i + 2, 1)) - 32) \ 4)
strDecoded = strDecoded + CHR$((ASC(MID$(strLine, i + 2, 1)) MOD 4) * 64 + _
ASC(MID$(strLine, i + 3, 1)) - 32)
NEXT i
sOut = sOut & strDecoded
strDecoded = ""
NEXT
FUNCTION = sOut
END FUNCTION


------------------


[This message has been edited by Borje Hagsten (edited January 28, 2003).]

IP: Logged

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c