Escapes a string so it can be safely used as a value in a URL component by replacing all characters that are not "unreserved characters" with percent‐escapes. See https://tools.ietf.org/html/rfc3986
Synopsis
Declared in <absl/strings/escaping.h>
[[nodiscard]]
std::string
UrlEscape(std::string_view input);
Description
Usage note: URLs use "reserved characters" (like ?, &, =, /) as structural syntax. This function escapes these syntax characters. The correct use of this function is to clean individual URL components before assembling them into the final URL structure. Do not run it on a fully constructed URL, as this will turn structural delimiters into URL component data.
Example (encoding "gift for mom & dad" as a URL query parameter):
std::string url = absl::StrFormat("https://www.google.com/search?q=%s", absl::UrlEscape("gift for mom & dad")); assert(url == "https://www.google.com/search?q=gift%20for%20mom%20%26%20dad");
Return Value
The escaped string.
|
Note
|
The return value should not be discarded. |
Parameters
Name |
Description |
input |
The URL component to escape. |
Created with MrDocs