Created
November 12, 2011 11:28
-
-
Save azyobuzin/1360409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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