using System.Collections.Generic;
public static void Main()
List<string> shouldPass = new List<string>() {
"http://foo.com/blah_blah",
"http://foo.com/blah_blah/",
"http://foo.com/blah_blah_(wikipedia)",
"http://foo.com/blah_blah_(wikipedia)_(again)",
"http://www.example.com/wpstyle/?p=364",
"https://www.example.com/foo/?bar=baz&inga=42&quux",
"http://userid:password@example.com:8080",
"http://userid:password@example.com:8080/",
"http://userid@example.com",
"http://userid@example.com/",
"http://userid@example.com:8080",
"http://userid@example.com:8080/",
"http://userid:password@example.com",
"http://userid:password@example.com/",
"http://142.42.1.1:8080/",
"http://foo.com/blah_(wikipedia)#cite-1",
"http://foo.com/blah_(wikipedia)_blah#cite-1",
"http://foo.com/unicode_(✪)_in_parens",
"http://foo.com/(something)?after=parens",
"http://☺.damowmow.com/",
"http://code.google.com/events/#&product=browser",
"http://foo.bar/?q=Test%20URL-encoded%20stuff",
"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
List<string> customParserResult = new List<string>();
foreach(string s in shouldPass) {
char[] buffer = new char[s.Length];
for(int i = 0; i < s.Length; i++){
(c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
customParserResult.Add(new string(buffer));
for(int i = 0; i < customParserResult.Count; i++){
string customParsed = customParserResult[i];
string original = shouldPass[i];
Console.WriteLine("Original: " + original);
Console.WriteLine("Encoded: " + HttpUtility.UrlEncode(original));
Console.WriteLine("Decoded: " + HttpUtility.UrlDecode(HttpUtility.UrlEncode(original)));
Console.WriteLine("Custom: " + customParsed);
Console.WriteLine("\n\n");