boost::urls::encode

Apply percent-encoding to a string

Synopsis

Declared in <boost/url/encode.hpp>

template<grammar::CharSet CS>
std::size_t
encode(
    char* dest,
    std::size_t size,
    core::string_view s,
    CS const& allowed,
    encoding_opts opt = {});

Description

This function applies percent-encoding to the string using the given options and character set. The destination buffer provided by the caller is used to store the result, which may be truncated if there is insufficient space.

Example


char buf[100];
assert( encode( buf, sizeof(buf), "Program Files", pchars ) == 15 );

Exception Safety

Throws nothing.

Specification

Return Value

The number of characters written to the destination buffer.

Parameters

NameDescription
destThe destination buffer to write to.
sizeThe number of writable characters pointed to by dest. If this is less than encoded_size(s), the result is truncated.
sThe string to encode.
allowedThe set of characters that is not percent-encoded.
optThe options for encoding. If this parameter is omitted, the default options are used.