URL-encoded slash in URL
If it’s only your last parameter, you could do: routes.MapRoute( “Default”, // Route name “{controller}/{action}/{*id}”, // URL with parameters new { controller = “Home”, action = “Index”, id = “” }); // Parameter defaults
If it’s only your last parameter, you could do: routes.MapRoute( “Default”, // Route name “{controller}/{action}/{*id}”, // URL with parameters new { controller = “Home”, action = “Index”, id = “” }); // Parameter defaults
For the URI query use urlencode/urldecode; for anything else use rawurlencode/rawurldecode. The difference between urlencode and rawurlencode is that urlencode encodes according to application/x-www-form-urlencoded (space is encoded with +) while rawurlencode encodes according to the plain Percent-Encoding (space is encoded with %20).
Here is a complete function (taken from PHPJS): function urldecode(str) { return decodeURIComponent((str+”).replace(/\+/g, ‘%20’)); }
I would always encode in UTF-8. From the Wikipedia page on percent encoding: The generic URI syntax mandates that new URI schemes that provide for the representation of character data in a URI must, in effect, represent characters from the unreserved set without translation, and should convert all other characters to bytes according to UTF-8, … Read more
Python 2 From the documentation: urllib.quote(string[, safe]) Replace special characters in string using the %xx escape. Letters, digits, and the characters ‘_.-‘ are never quoted. By default, this function is intended for quoting the path section of the URL.The optional safe parameter specifies additional characters that should not be quoted — its default value is … Read more
I had significant headaches with these methods before, I recommend you avoid any variant of UrlEncode, and instead use Uri.EscapeDataString – at least that one has a comprehensible behavior. Let’s see… HttpUtility.UrlEncode(” “) == “+” //breaks ASP.NET when used in paths, non- //standard, undocumented. Uri.EscapeUriString(“a?b=e”) == “a?b=e” // makes sense, but rarely what you // … Read more
It will depend on your purpose. If interoperability with other systems is important then it seems rawurlencode is the way to go. The one exception is legacy systems which expect the query string to follow form-encoding style of spaces encoded as + instead of %20 (in which case you need urlencode). rawurlencode follows RFC 1738 … Read more
This behaves as expected. The URLEncoder implements the HTML Specifications for how to encode URLs in HTML forms. From the javadocs: This class contains static methods for converting a String to the application/x-www-form-urlencoded MIME format. and from the HTML Specification: application/x-www-form-urlencoded Forms submitted with this content type must be encoded as follows: Control names and … Read more
To escape the characters you want is a little more work. Example code iOS7 and above: NSString *unescaped = @”http://www”; NSString *escapedString = [unescaped stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; NSLog(@”escapedString: %@”, escapedString); NSLog output: escapedString: http%3A%2F%2Fwww The following are useful URL encoding character sets: URLFragmentAllowedCharacterSet “#%<>[\]^`{|} URLHostAllowedCharacterSet “#%/<>?@\^`{|} URLPasswordAllowedCharacterSet “#%/:<>?@[\]^`{|} URLPathAllowedCharacterSet “#%;<>?[\]^`{|} URLQueryAllowedCharacterSet “#%<>[\]^`{|} URLUserAllowedCharacterSet “#%/:<>?@[\]^` Creating a … Read more
Use curl –data-urlencode; from man curl: This posts data, similar to the other –data options with the exception that this performs URL-encoding. To be CGI-compliant, the <data> part should begin with a name followed by a separator and a content specification. Example usage: curl \ –data-urlencode “paramName=value” \ –data-urlencode “secondParam=value” \ http://example.com See the man … Read more