[#absl-UrlEscapePlus] = xref:absl.adoc[absl]::UrlEscapePlus :relfileprefix: ../ :mrdocs: Escapes a string so it can be safely used as a value for application/x‐www‐form‐urlencoded (HTML form submissions). == Synopsis Declared in `<absl/strings/escaping.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[nodiscard]] std::string UrlEscapePlus(std::string_view input); ---- == Description Historically web browsers have also used this form of escaping for query parameters. UrlEscapePlus() differs from UrlEscape() in that space (' ') is encoded to plus ("+") instead of "%20". According to the URI specification (RFC 3986), the correct way to escape a space anywhere in a URL (including the query string) is "%20". Using "%20" in a query parameter will work universally. Some strict URL parsers (especially outside of web browsers/web servers) follow RFC 3986 strictly and will treat a literal '+' in the query string as a literal plus sign, rather than decoding it to a space. Recommendation: Use UrlEscapePlus() only if you are specifically implementing or interacting with a system that strictly expects "application/x‐www‐form‐urlencoded" formatting. For general URL construction, UrlEscape() is the correct and safest choice. Example (encoding "gift for mom & dad" as a URL query parameter): std::string url = absl::StrFormat("https://www.google.com/search?q=%s", absl::UrlEscapePlus( "gift for mom & dad")); assert(url == "https://www.google.com/search?q=gift+for+mom+%26+dad"); == Return Value The escaped string. [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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#