Home | Libraries | People | FAQ | More |
Return the number of bytes needed to store a string with percent-encoding applied.
Defined in header <boost/url/encode.hpp>
template< class CharSet = grammar::all_chars_t> std::size_t encoded_size( string_view s, encode_opts const& opt = {}, CharSet const& allowed = {});
This function examines the characters in the string to determine the number of bytes necessary if the string were to be percent encoded using the given options and character set. No encoding is actually performed.
Find the number of bytes needed to encode a string without transforming ' ' to '+'.
encode_opts opt; opt.space_to_plus = false; std::size_t n = encoded_size( "My Stuff", pchars, opt ); assert( n == 10 );
Find the number of bytes needed to encode a string when transforming ' ' to '+'.
encode_opts opt; opt.space_to_plus = true; std::size_t n = encoded_size( "My Stuff", opt, pchars ); assert( n == 8 );
Throws nothing.
The number of bytes needed, excluding any null terminator.
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 |
Convenience header <boost/url.hpp>