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

Escapes a string so it can be safely used as a value in a URL component by replacing all characters that are not &quot;unreserved characters&quot; with percent&hyphen;escapes&period; See https&colon;&sol;&sol;tools&period;ietf&period;org&sol;html&sol;rfc3986

== 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
UrlEscape(std::string&lowbar;view input);
----

== Description

Usage note&colon; URLs use &quot;reserved characters&quot; (like ?, &amp;, &equals;, &sol;) as structural syntax&period; This function escapes these syntax characters&period; The correct use of this function is to clean individual URL components _before_ assembling them into the final URL structure&period; Do not run it on a fully constructed URL, as this will turn structural delimiters into URL component data&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;UrlEscape(&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%20for%20mom%20%26%20dad&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]#
