FW: Safe URL encoding (in hex)
Brian K. White
brian at aljex.com
Fri May 27 12:33:55 PDT 2011
On 5/26/2011 1:13 PM, Mike Schwartz wrote:
> 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 ***
There is also a matching url un-encoder.
http://www.aljex.com/bkw/filepro/#urlenc
--
bkw
More information about the Filepro-list
mailing list