Boost.URL Logo

PrevUpHomeNext
pct_decode (1 of 2 overloads)

Write a string with percent-decoding into a buffer.

Synopsis

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

template<
    class CharSet>
result< std::size_t >
pct_decode(
    char* dest,
    char const* end,
    string_view s,
    CharSet const& allowed,
    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, pchars, 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. If the destination buffer is too small to hold the result, the result is set to error::no_space.

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.

allowed

The set of characters allowed to appear unescaped. This type must satisfy the requirements of CharSet. If this parameter is omitted, then no characters are considered special. The character set is ignored if opt.non_normal_is_error == false.

Specification
See Also

pct_decode_bytes_unchecked, pct_decode_opts, pct_decode_unchecked. validate_pct_encoding.

Convenience header <boost/url.hpp>


PrevUpHomeNext