[Gambas-user] Drag'n'drop and url decode

werner 007 admin at ...1080...
Mon Feb 2 19:22:18 CET 2009


Hallo Ivan

Once i had the same task to do. 
The replace(...,..) function is maybe the best for  "file://" and "/r/n".
For decoding url stuff has Benoit recommended to look at CGI.Decode().
I did it not because my lazyness and my code does what it should so far.
The hole thread is here:
<url>http://www.nabble.com/URL-encoding-%22-20%22-td21216641.html#a21216641</url>


Regards, Werner(007)


Actually my decode looks so, it is not a pick of the bunch but it works:


> PUBLIC SUB grdView01_Drop()
>   urldecode(Drag.Data)
> END
> PUBLIC SUB grdView02_Drop()
>   urldecode(Drag.Data)
> END
> PRIVATE SUB urldecode(strin AS String)
>   DIM strFile AS String
>   DIM strout AS String
>   DIM i AS Integer
>   IF UCase(Left(strin, 8)) = "FILE:///" THEN 
>     'check for the right file extensions which allowed
>     IF (InStr(".txt.doc.xml", file.Ext(strin)) > 0) THEN
>       strin = Replace(Replace(strin, "\r\n", ""), "file://", "")
>       ' check if has encoded stuff
>       IF InStr(strin, "%") THEN
>         FOR i = 1 TO Len(strin)
>             IF Mid(strin, i, 1) = "%" THEN 
>               IF IsNumber(Val(Mid(strin, i + 1, 2))) THEN 
>                 strout &= Chr((CInt(Mid(strin, i + 1, 2)) / 10) * 16)
>                 i = i + 2
>               ELSE 
>                 strout = strout & Mid(strin, i, 1)
>               END IF
>             ELSE 
>               strout = strout & Mid(strin, i, 1)
>             END IF
>         NEXT
>       ELSE 
>         strout = strin
>       END IF
>       load_file(strout)
>     END IF
>   END IF
> END
> 

-- 
View this message in context: http://www.nabble.com/Drag%27n%27drop-and-url-decode-tp21789686p21795249.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list