Boost.URL Logo

PrevUpHomeNext
pct_decode (2 of 2 overloads)

Write a string with percent-decoding into a buffer.

Synopsis

Defined in header <boost/url/pct_encoding.hpp>

result< std::size_t >
pct_decode(
    char* dest,
    char const* end,
    string_view s,
    pct_decode_opts const& opt = {});
Description

This function applies percent-decoding to the given percent-encoded string, by converting escape sequences into their character equivalent. The function returns the number of bytes written to the destination buffer, which may be less than the size of the output area.

Example
char *dest = new char[MAX_LENGTH];
error_code ec;
std::size_t decoded_size = pct_decode( dest, dest + MAX_LENGTH,
        "Program%20Files", ec, pct_decode_opts{});

assert( ! ec.failed() );
assert( decoded_size == 13 );
assert( strncmp( "Program Files", dest, decoded_size ) == 0 );
Exception Safety

Throws nothing.

Return Value

The number of bytes written to the destination buffer, which does not include any null termination.

Parameters

Name

Description

dest

A pointer to the beginning of the output buffer.

end

A pointer to one past the end of the output buffer.

s

The string to decode.

opt

The options for decoding. If this parameter is omitted, the default options will be used.

Specification
See Also

pct_decode_bytes_unchecked, pct_decode_opts, pct_decode_unchecked. validate_pct_encoding.

Convenience header <boost/url.hpp>


PrevUpHomeNext