
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM
|
COMMUNICATION
Encode in HTTP
Here's where I come in...
The easiest way is to trap all non alpha-numeric characters(except maybe the slash:)
And everything is encoded into hexadecimal, just use a "%" instead of an "&H", so here's your program... keep in mind that I'm not following the spec exactly, this is more of a "safe way". You can find the RFC(request for comments) form on the internet if you reallllly need to conform to the spec. (Nothing will break, in other words.):
COMPILE 0,_caseInsensitive
beginning$ = "http://"
http$=""
myfile$ = FILES$(_fOpen,,,Vref%)
LONG IF myfile$<>""
http$=beginning$
FOR ex& = 1 TO LEN(myfile$)
es$ = MID$(myfile$,ex&,1)
et$ = UCASE$(es$)
LONG IF et$<"A" OR et$>"Z"
LONG IF et$<"0" OR et$>"9"
SELECT CASE et$
CASE "-","!","$","^","*","(",")"
http$=http$+es$
CASE ",",".",";"
http$=http$+es$
CASE "'",CHR$(34)
http$=http$+es$
CASE ELSE
hx$ = "00" + HEX$(ASC(es$))
hx$ = RIGHT$(hx$,2)
http$ = http$ + "%" + hx$
END SELECT
XELSE
http$=http$+es$
END IF
XELSE
http$=http$+es$
END IF
NEXT ex&
END IF
WINDOW #1,"httptext",(0,0)-(320,200)
PRINT http$
DO
HANDLEEVENTS
UNTIL FN BUTTON
FLUSHEVENTS
END
|