How to encode the plus (+) symbol in URL

url encode
url encode plus
php url encode
c# url encode
html encode
url encoding characters
how to pass special characters in url

The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) sign in the email body with blank space. It looks like it only happens with the + sign. Any suggestions on how to remedy this? ( I am working the ASP.NET web page) subject&body=Hi there+Hello there

(In the body email, "Hi there+Hello there" will show up as "Hi there Hello there")

The + character has a special meaning in a url => it means whitespace. If you want to use the + sign you need to URL encode it:


Here's an example of how you could properly generate urls in .NET:

var uriBuilder = new UriBuilder("");

var values = HttpUtility.ParseQueryString(string.Empty);
values["view"] = "cm";
values["tf"] = "0";
values["to"] = "";
values["su"] = "some subject";
values["body"] = "Hi there+Hello there";

uriBuilder.Query = values.ToString();


The result

How to encode the plus (+) symbol in URL, For example, spaces in a string are either encoded with %20 or replaced with the plus sign ( + ). If you use a pipe character ( | ) as a separator, be sure to encode  How to encode the plus (+) symbol in URL. The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) sign in the email body with blank space. It looks like it only happens with the + sign.

Is you want a plus (+) symbol in the body you have to encode it as 2B.

For example: Try this

How to Pass a Plus Sign to a URL?, URL Encoding Issue for Plus Symbol (%2B) #210. Closed. imaurer opened this issue on Jun 16, 2016 · 11 comments. Closed  Your request is getting rejected by request filtering module. See this blog on interaction between urlrewrite and request filtering. See this blog which explains request filtering behavior of rejected URLs with '+' and how to fix it.

for javascript language use encodeURIComponent function to encode special characters

URL Encoding | Maps URLs, The + character is valid in url query strings as a substitute for space or its We cannot prevent users of our API from using plus signs to encode  So, if you want the + sign to be preserved when a JavaScript is fetching a URL with + signs in its query parameters and a server side script would process the query parameters after URL-decoding it, you should URL-encode the query parameters in the URL before using issuing the HTTP get request so that all + signs are converted to %2B's when the request reaches the server side script.

It's safer to always percent-encode all characters except those defined as "unreserved" in RFC-3986.

unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

So, percent-encode the plus character and other special characters.

The problem that you are having with pluses is because, according to RFC-1866 (HTML 2.0 specification), paragraph 8.2.1. subparagraph 1., "The form field names and values are escaped: space characters are replaced by `+', and then reserved characters are escaped"). This way of encoding form data is also given in later HTML specifications, look for relevant paragraphs about application/x-www-form-urlencoded.

URL Encoding Issue for Plus Symbol (%2B) · Issue #210 · django , Percent-encoding, also known as URL encoding, is a mechanism for encoding information in a characters, and percent-encoding, in some form or other: RFC 3986 / STD 66 (plus errata), the current generic URI syntax specification. So if you need to URL-encode a string for inclusion in part of a URL, it is always safe to replace spaces with %20 and pluses with %2B. This is what eg. encodeURIComponent() does in JavaScript. Unfortunately it's not what urlencode does in PHP (rawurlencode is safer).

+ (Plus) in URL parameter converted to %2B · Issue #3042 · angular , Fragment identifiers and relative URIs are not involved in the basic URL In either case, the encoding may use those characters allowed by the BNF syntax, Within the query string, the plus sign is reserved as shorthand notation for a space. URL Encoding. URLs can only be sent over the Internet using the ASCII character-set. If a URL contains characters outside the ASCII set, the URL has to be converted. URL encoding converts non-ASCII characters into a format that can be transmitted over the Internet.

Percent-encoding, The <space> character needs to be encoded because it is not a valid URL character. Also, some characters, such as "~" might not transport  URL encode your data in a hassle-free way, or decode it into human-readable format. URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances.

Universal Resource Identifiers: Recommendations, urldecode — Decodes URL-encoded string Plus symbols ('+') are decoded to a space character. foo.php?myvar=%C2%BA (The "right" url encoding) Encoding space characters to plus sign (+) using quote_plus() function The quote() function encodes space characters to %20 . If you want to encode space characters to plus sign ( + ), then you can use another function named quote_plus provided by urllib.parse package.

  • The RFC clearly says that the + sign can be used unencoded, and also if it had to be encoded, there is no reason to turn it into a "space" character. Maybe you can point us to a proper document of a standard mentioning what is that of translating a + symbol into a space symbol and vice-versa.
  • Yeah what are you talking about? I've never seen an RFC or anything that says + means spaces....
  • Warning: If you use the Uri property of UriBuilder you will get a bad result. uriBuilder.Uri.ToString() in your example would return Hi+there+Hello+there. Using uriBuilder.Uri.AbsoluteUri seems to work correctly and suggests this is fixed in .NET 4.5. As far as RFC goes, the HTML 4 spec says the URL querystring is of type application/x-www-form-urlencoded which itself defines (+) as meaning space. So it's not an RFC but is part of the HTML standard.
  • @freedrull but it really works this way - that shows the number of upvotes
  • Note that IIS considers this "double encoding" and will often block a url loaded this way with this error: HTTP Error 404.11 - Not Found The request filtering module is configured to deny a request that contains a double escape sequence.