[#boost-urls-decode-03] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::decode :relfileprefix: ../../ :mrdocs: Apply percent‐decoding to an arbitrary string == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/decode.hpp#Lundefined[boost/url/decode.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- system::result<std::size_t> decode( char* dest, std::size_t size, core::string_view s, xref:boost/urls/encoding_opts.adoc[encoding_opts] opt = {}) noexcept; ---- == Description This function percent‐decodes the specified string into the destination buffer provided by the caller. The input is validated first; malformed escapes cause the returned result to hold an error instead of a size. If the buffer is too small, the output is truncated and the number of bytes actually written is returned. == Example [,cpp] ---- char buf[100]; auto n = decode( buf, sizeof(buf), "Program%20Files" ); assert( n && *n == 13 ); ---- == Exception Safety Throws nothing. Validation errors are reported in the returned result. == Specification * https://datatracker.ietf.org/dodc/html/rfc3986#section-2.1[2.1. Percent‐Encoding (rfc3986)] == Return Value The number of characters written to the destination buffer, or an error. == Parameters [cols="1,4"] |=== |Name|Description | *dest* | The destination buffer to write to. | *size* | The number of writable characters pointed to by `dest`. If this is less than the decoded size, the result is truncated. | *s* | The string to decode. | *opt* | The decoding options. If omitted, the default options are used. |=== == See Also xref:boost/urls/decoded_size.adoc[`decoded_size`], xref:boost/urls/encoding_opts.adoc[`encoding_opts`], xref:boost/urls/make_pct_string_view.adoc[`make_pct_string_view`]. [.small]#Created with https://www.mrdocs.com[MrDocs]#