Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
encode (2 of 2 overloads)

Return a percent-encoded string.

Synopsis

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

template<
    class StringToken = string_token::return_string,
    class CharSet>
StringToken::result_type
encode(
    string_view s,
    CharSet const& unreserved,
    encoding_opts opt = {},
    StringToken&& token = {});
Description

This function applies percent-encoding to the string using the given options and character set, and returns the result as a string when called with default arguments.

Example
encoding_opts opt;
opt.space_as_plus = true;
std::string s = encode( "My Stuff", opt, pchars );

assert( s == "My+Stuff" );
Exception Safety

Calls to allocate may throw.

Return Value

The string

Parameters

Name

Description

s

The string to encode.

unreserved

The set of characters that is not percent-encoded.

opt

The options for encoding. If this parameter is omitted, the default options are used.

token

A string token.

Specification
See Also

encode, encoded_size, encoding_opts,

Convenience header <boost/url.hpp>


PrevUpHomeNext