Skip to content

Instantly share code, notes, and snippets.

@azyobuzin
Created November 12, 2011 11:28
Show Gist options
  • Save azyobuzin/1360409 to your computer and use it in GitHub Desktop.
Save azyobuzin/1360409 to your computer and use it in GitHub Desktop.
(def UrlEncode (\ [value:String]
String.(Join ""
Encoding.UTF8.(GetBytes value)
.(Select { $0.(to Int32) })
.(Select {
(&&
(< $0 0x80)
(!= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"
.(IndexOf $0.(to Char))
-1
)
)
.(cond
$0.(to Char).(ToString)
(+ "%" String.(Format "{0:X2}" $0))
)
})
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment