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

Apply percent&hyphen;decoding to an arbitrary string

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
system::result&lt;std::size&lowbar;t&gt;
decode(
    char* dest,
    std::size&lowbar;t size,
    core::string&lowbar;view s,
    xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts] opt = &lcub;&rcub;) noexcept;
----

== Description

This function percent&hyphen;decodes the specified string into the destination buffer provided by the caller&period; The input is validated first&semi; malformed escapes cause the returned result to hold an error instead of a size&period; If the buffer is too small, the output is truncated and the number of bytes actually written is returned&period;

== Example

[,cpp]
----
char buf[100];
auto n = decode( buf, sizeof(buf), "Program%20Files" );
assert( n && *n == 13 );
----
== Exception Safety

Throws nothing&period; Validation errors are reported in the returned result&period;

== Specification

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

== Return Value

The number of characters written to the destination buffer, or an error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *dest*
| The destination buffer to write to&period;
| *size*
| The number of writable characters pointed to by `dest`&period; If this is less than the decoded size, the result is truncated&period;
| *s*
| The string to decode&period;
| *opt*
| The decoding options&period; If omitted, the default options are used&period;
|===

== See Also

xref:boost/urls/decoded_size.adoc[`decoded&lowbar;size`], xref:boost/urls/encoding_opts.adoc[`encoding&lowbar;opts`], xref:boost/urls/make_pct_string_view.adoc[`make&lowbar;pct&lowbar;string&lowbar;view`]&period;


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