collect-based URL encoder
1 2 url-encode: func [ 3 {URL-encode a string} 4 data "String to encode" 5 /local normal-char new-data 6 ][ 7 normal-char: charset [ 8 #"A" - #"Z" #"a" - #"z" 9 #"@" #"." #"*" #"-" #"_" 10 #"0" - #"9" 11 ] 12 data: form data 13 collect/into ch [ 14 forall data [ 15 ch: either find normal-char first data [first data] [ 16 rejoin ["%" to-string skip tail (to-hex to-integer first data) -2] 17 ] 18 ] 19 ] copy "" 20 ]