Home | Libraries | People | FAQ | More |
Return a string with percent-encoding applied.
Defined in header <boost/url/encode.hpp>
template< class CharSet = grammar::all_chars_t, class Allocator = std::allocator<char>> std::basic_string< char, std::char_traits< char >, Allocator > encode_to_string( string_view s, encode_opts const& opt = {}, CharSet const& allowed = {}, 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.
encode_opts opt; opt.space_to_plus = true; std::string s = 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 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 |
|
The options for encoding. If this parameter is omitted, the default options will be used. |
|
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 |
encode
,
encoded_size
,
encode_opts
,
Convenience header <boost/url.hpp>