Return the number of bytes needed to store a string with percent-encoding applied.
Defined in header <boost/url/pct_encoding.hpp>
template< class CharSet> std::size_t pct_encode_bytes( string_view s, CharSet const& allowed, pct_encode_opts const& opt = {});
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 '+'.
pct_encode_opts opt; opt.space_to_plus = false; std::size_t n = pct_encode_bytes( "My Stuff", pchars, opt ); assert( n == 10 );
Find the number of bytes needed to encode a string when transforming ' ' to '+'.
pct_encode_opts opt; opt.space_to_plus = true; std::size_t n = pct_encode_bytes( "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 |
pct_decode
,
pct_encode
,
pct_encode_opts
.
Convenience header <boost/url.hpp>