Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

decode

Validate and decode a string view.

Synopsis

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

template<
    class CharSet = grammar::all_chars_t>
result< decode_view >
decode(
    string_view s,
    decode_opts const& opt = {},
    CharSet const& allowed = {});
Description

This function returns a view that applies percent-decoding to the given percent-encoded string, by converting escape sequences into their character equivalent. The function validates the input string and returns a view of the decoded bytes. If the input string is invalid, the result contains an error.

Example
result< decode_view > r = decode( "Program%20Files" );
assert( r.has_value() );

decode_view v = *r;
assert( v == "Program Files" );
assert( v.size() == 13 );
assert( v.encoded().size() == 15 );
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

s

The string to decode.

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.

opt

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

Specification
See Also

decode_opts.

Convenience header <boost/url.hpp>


PrevUpHomeNext