[#absl-UrlEscapePlus]
= xref:absl.adoc[absl]::UrlEscapePlus
:relfileprefix: ../
:mrdocs:

Escapes a string so it can be safely used as a value for application&sol;x&hyphen;www&hyphen;form&hyphen;urlencoded (HTML form submissions)&period;

== Synopsis

Declared in `&lt;absl&sol;strings&sol;escaping&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
std::string
UrlEscapePlus(std::string&lowbar;view input);
----

== Description

Historically web browsers have also used this form of escaping for query parameters&period;

UrlEscapePlus() differs from UrlEscape() in that space (&apos; &apos;) is encoded to plus (&quot;&plus;&quot;) instead of &quot;%20&quot;&period; According to the URI specification (RFC 3986), the correct way to escape a space anywhere in a URL (including the query string) is &quot;%20&quot;&period; Using &quot;%20&quot; in a query parameter will work universally&period;

Some strict URL parsers (especially outside of web browsers&sol;web servers) follow RFC 3986 strictly and will treat a literal &apos;&plus;&apos; in the query string as a literal plus sign, rather than decoding it to a space&period;

Recommendation&colon; Use UrlEscapePlus() only if you are specifically implementing or interacting with a system that strictly expects &quot;application&sol;x&hyphen;www&hyphen;form&hyphen;urlencoded&quot; formatting&period; For general URL construction, UrlEscape() is the correct and safest choice&period;

Example (encoding &quot;gift for mom &amp; dad&quot; as a URL query parameter)&colon;

std&colon;&colon;string url &equals; absl&colon;&colon;StrFormat(&quot;https&colon;&sol;&sol;www&period;google&period;com&sol;search?q&equals;%s&quot;, absl&colon;&colon;UrlEscapePlus( &quot;gift for mom &amp; dad&quot;))&semi; assert(url &equals;&equals; &quot;https&colon;&sol;&sol;www&period;google&period;com&sol;search?q&equals;gift&plus;for&plus;mom&plus;%26&plus;dad&quot;)&semi;

== Return Value

The escaped string&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *input*
| The URL component to escape&period;
|===


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