Return a string with percent-encoding applied.
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 = {});
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.
pct_encode_opts opt; opt.space_to_plus = true; std::string s = pct_encode( "My Stuff", opt, pchars ); assert( s == "My+Stuff" );
Calls to allocate may throw.
A std::basic_string
holding the encoded string,
using the specified allocator.
Name |
Description |
---|---|
|
The string to encode. |
|
The options for encoding. If this parameter is omitted, the default options will be used. |
|
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 |
|
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 |
pct_encode
,
pct_encode_bytes
,
pct_encode_opts
,
Convenience header <boost/url.hpp>