base:EncodeURL()

You can post your code snippets here for others to use and learn from

base:EncodeURL()

Postby djrikki » Wed Apr 15, 2015 11:46 pm

Returns a UTF-8 string as a RFC 3986 encoded URL.

Code: Select all
Global base
base = {}

;; base:EncodeURL(data$)
; Encodes a URL to RFC 3986
Function base:EncodeURL(data$)

    data$ = ReplaceStr(data$,"%","%25") ; must be done first
    data$ = ReplaceStr(data$,"!","%21")
    data$ = ReplaceStr(data$,"*","%2A")
    data$ = ReplaceStr(data$,"'","%27")
    data$ = ReplaceStr(data$,"(","%28")
    data$ = ReplaceStr(data$,")","%29")
    data$ = ReplaceStr(data$,";","%3B")
    data$ = ReplaceStr(data$,":","%3A")
    data$ = ReplaceStr(data$,"@","%40")
    data$ = ReplaceStr(data$,"&","%26")
    data$ = ReplaceStr(data$,"=","%3D")
    data$ = ReplaceStr(data$,"+","%2B")
    data$ = ReplaceStr(data$,"$","%24")
    data$ = ReplaceStr(data$,",","%2C")
    data$ = ReplaceStr(data$,"/","%2F")
    data$ = ReplaceStr(data$,"?","%3F")
    data$ = ReplaceStr(data$,"#","%23")
    data$ = ReplaceStr(data$,"[","%5B")
    data$ = ReplaceStr(data$,"]","%5D")
    data$ = ReplaceStr(data$,"<","%3C")
    data$ = ReplaceStr(data$,">","%3E")
    data$ = ReplaceStr(data$,".","%2E")
    data$ = ReplaceStr(data$,"\"","%22")
    data$ = ReplaceStr(data$,"{","%7B")
    data$ = ReplaceStr(data$,"}","7D")
    data$ = ReplaceStr(data$,"|","7C")
    data$ = ReplaceStr(data$,"\\","%5C")
    data$ = ReplaceStr(data$,"-","%2D")
    data$ = ReplaceStr(data$,"`","%60")
    data$ = ReplaceStr(data$,"_","%5F")
    data$ = ReplaceStr(data$,"^","%5E")
    data$ = ReplaceStr(data$," ","%20")
    data$ = ReplaceStr(data$,"\n","%0A")

    Return (data$)
EndFunction
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
djrikki
 
Posts: 645
Joined: Wed Apr 06, 2011 12:26 am

Return to Code snippets area

Who is online

Users browsing this forum: No registered users and 1 guest

cron