FW: Safe URL encoding (in hex)
Mike Schwartz
mschw at athenet.net
Thu May 26 10:13:24 PDT 2011
I need to convert the ' to ' or %27 using an edit.
I'm not good at defining edits and sure would appreciate some help.
I need to replace the ' with its HTML equivalent before writing out ajax
script that uses ' for strings and have names with ' in them.
Thanks,
Linda
----- ----- -----------------------------------------------------
This is best done in processing. Here's some code I got from Brian White's
web site a few years ago:
----- ----- -----
Why? See:
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
1 If:' brian at aljex.com - urlenc
Then:' convert text into url-safe (url-encoded) text
2 If:' example plain text in : blah)^%$#@
Then:' example url text out : blah%29%5E%25%24%23%40%0D%0A
3 If:' definition: url encoding is:
Then:' % + <hex ascii value of character in latin1 character set>
4 If:' usage: declare global urlenc_di, urlenc_do
Then:' urlenc_di = "input string" ; call "cgi/urlenc" ; show urlenc_do
5 If:' data-in data-out
Then:declare extern urlenc_di, urlenc_do
6 If:' position length inchar outchar
Then:declare urlenc_dp, urlenc_dl, urlenc_ic, urlenc_oc
7 If:
Then:urlenc_dp = "1" ; urlenc_dl = len(urlenc_di) ; urlenc_do = ""
8nxtchrIf:
Then:urlenc_ic = mid(urlenc_di,urlenc_dp,"1") ; urlenc_oc = urlenc_ic
9 If:"$&+,/:;=?@ <>#%{}|^~[]`'"{chr("92"){chr("34") co urlenc_ic
Then:urlenc_oc = "%" { base(asc(urlenc_ic),"10","16")
10 If:
Then:urlenc_do = urlenc_do & urlenc_oc
11 If:urlenc_dp lt urlenc_dl
Then:urlenc_dp = urlenc_dp + "1" ; goto nxtchr
*** Mike Schwartz ***
More information about the Filepro-list
mailing list