[#boost-urls-decode-07]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::decode
:relfileprefix: ../../
:mrdocs:

Return a percent&hyphen;decoded string

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:boost/urls/string_token/StringToken.adoc[string&lowbar;token::StringToken] StringToken = xref:boost/urls/string_token/return_string.adoc[string&lowbar;token::return&lowbar;string]&gt;
system::result&lt;StringToken::result&lowbar;type&gt;
decode(
    core::string&lowbar;view s,
    xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts] opt = &lcub;&rcub;,
    StringToken&& token = &lcub;&rcub;);
----

== Description

This function percent&hyphen;decodes the specified string and returns the result using any xref:boost/urls/string_token.adoc[`string&lowbar;token`]&period; The string is validated before decoding&semi; malformed escapes cause the returned result to hold an error&period;

== Example

[,cpp]
----
auto plain = decode( "My%20Stuff" );
assert( plain && *plain == "My Stuff" );
----
== Exception Safety

Calls to allocate may throw&period; Validation errors are reported in the returned result&period;

== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-2.1[2&period;1&period; Percent&hyphen;Encoding (rfc3986)]

== Return Value

A result containing the decoded string in the format described by the passed string token&period;

== Parameters

[cols="1,4"]
|===
|Name|Description

| *s*
| The string to decode&period;
| *opt*
| The decoding options&period; If omitted, the default options are used&period;
| *token*
| A string token&period;
|===

== See Also

xref:boost/urls/decode-01.adoc[`decode`], xref:boost/urls/decoded_size.adoc[`decoded&lowbar;size`], xref:boost/urls/encoding_opts.adoc[`encoding&lowbar;opts`], xref:boost/urls/string_token/return_string.adoc[`string&lowbar;token&colon;&colon;return&lowbar;string`]&period;


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