boost::urls::decode

Apply percent‐decoding to an arbitrary string

Synopsis

Declared in <boost/url/decode.hpp>

system::result<std::size_t>
decode(
    char* dest,
    std::size_t size,
    core::string_view s,
    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

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.

Return Value

The number of characters written to the destination buffer, or an error.

Parameters

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.