[#boost-urls-encoding_opts-space_as_plus]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts]::space&lowbar;as&lowbar;plus
:relfileprefix: ../../../
:mrdocs:

True if spaces encode to and from plus signs

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/encoding_opts.hpp#Lundefined[boost&sol;url&sol;encoding&lowbar;opts&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
bool space&lowbar;as&lowbar;plus = false;
----

== Description

Although not prescribed by RFC 3986, many applications decode plus signs in URL queries as spaces&period; In particular, the form&hyphen;urlencoded Media Type in HTML for submitting forms uses this convention&period;

This option controls whether the PLUS character (&quot;&plus;&quot;) is used to represent the SP character (&quot; &quot;) when encoding or decoding&period;

When this option is `true`, both the encoded SP (&quot;%20&quot;) and the PLUS character (&quot;&plus;&quot;) represent a space (&quot; &quot;) when decoding&period; To represent a plus sign, its encoded form (&quot;%2B&quot;) is used&period;

The xref:boost/urls/encode-0d.adoc[`encode`] and xref:boost/urls/encoded_size.adoc[`encoded&lowbar;size`] functions will encode spaces as plus signs when this option is `true`, regardless of the allowed character set&period; They will also encode plus signs as &quot;%2B&quot; when this option is `true`, regardless of the allowed character set&period;

Note that when a URL is normalized, all unreserved percent&hyphen;encoded characters are replaced with their unreserved equivalents&period; However, normalizing the URL query maintains the decoded and encoded &quot;&amp;&equals;&plus;&quot; as they are because they might have different meanings&period;

This behavior is not optional because normalization can only mitigate false negatives, but it should eliminate false positives&period; Making it optional would allow a false positive because there&apos;s at least one very relevant schema (HTTP) where a decoded or encoded &quot;&amp;&equals;&plus;&quot; has different meanings and represents different resources&period;

The same considerations apply to URL comparison algorithms in the library, as they treat URLs as if they were normalized&period;

== Specification

* https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1[application&sol;x&hyphen;www&hyphen;form&hyphen;urlencoded (w3&period;org)]
* https://datatracker.ietf.org/doc/html/rfc1866#section-8.2.1[The form&hyphen;urlencoded Media Type (RFC 1866)]
* https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.2.2[Section 6&period;2&period;2&period;2&period; Percent&hyphen;Encoding Normalization (RFC 3986)]


[.small]#Created with https://www.mrdocs.com[MrDocs]#
