Boost.URL Logo

PrevUpHomeNext

pct_encode_to_string

Return a string with percent-encoding applied.

Synopsis

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

template<
    class CharSet,
    class Allocator = std::allocator<char>>
std::basic_string< char, std::char_traits< char >, Allocator >
pct_encode_to_string(
    string_view s,
    CharSet const& allowed,
    pct_encode_opts const& opt = {},
    Allocator const& a = {});
Description

This function applies percent-encoding to the given plain string, by escaping all characters that are not in the specified CharSet. The result is returned as a std::basic_string, using the optionally specified allocator.

Example
pct_encode_opts opt;
opt.space_to_plus = true;
std::string s = pct_encode( "My Stuff", opt, pchars );

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

Calls to allocate may throw.

Return Value

A std::basic_string holding the encoded string, using the specified allocator.

Parameters

Name

Description

s

The string to encode.

opt

The options for encoding. 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.

a

An optional allocator the returned string will use. If this parameter is omitted, the default allocator is used. In this case the return type will be std::string.

Specification
See Also

pct_encode, pct_encode_bytes, pct_encode_opts,

Convenience header <boost/url.hpp>


PrevUpHomeNext