Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

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  ]
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS