Try my new website:
www.urcho.com
- the new SIMPLE social network
Sign up
|
284
members |
114
snippets
Search for:
ALL
POPULAR
File Controls
Multiplayer Code
2D Effects
3D Effects
Oldskool demos
Basic Functions
Maths/Physics
Sound
Tutorials
Misc
Username:
Password:
Sign up
URLEncode by Raph
[
back
]
Author:
Archive
| Viewed:
555
times | Language:
BlitzMax
| Category:
Multiplayer Code
Function URLEncode:String(t:String) Local newString:String For i = 0 To Len(t) c:String = t[i..i+1] asciival = Asc(c) If asciival > 32 And asciival < 123 ' handle replacing the special set of chars c = Replace(c,"%","%25") c = Replace(c,"<","%3C") c = Replace(c,">","%3E") c = Replace(c,"\","%5C") c = Replace(c,"^","%5E") c = Replace(c,"[","%5B") c = Replace(c,"]","%5D") c = Replace(c,"+","%2B") c = Replace(c,"$","%24") c = Replace(c,",","%2C") c = Replace(c,"@","%40") c = Replace(c,":","%3A") c = Replace(c,";","%3B") c = Replace(c,"/","%2F") c = Replace(c,"!","%21") c = Replace(c,"#","%23") c = Replace(c,"?","%3F") c = Replace(c,"=","%3D") c = Replace(c,"&","%26") newString:+c Else hexstr$ = Hex(asciival) newhexstr$ = "%" + hexstr[Len(hexstr)-2..Len(hexstr)] newstring:+newhexstr EndIf Next newstring = newstring[..Len(newstring)-3] Return newstring End Function
Author Comments:
This function replaces all the special characters in a string with the hex codes in %nn format for use in URLs, POSTs, GETs, etc. For example, "This is URL encoded!" becomes "This%20is%20URL%20encoded%21" I threw it together quickly, so its not Strict and it requires brl.retro. Also, for some reason, it was sticking an extra space on the end, so theres a hack to strip that off. ;)
Login or
create an account
to comment on this snippet