Write a string with percent-encoding into a buffer.
Defined in header <boost/url/pct_encoding.hpp>
template< class CharSet> std::size_t pct_encode( char* dest, char const* end, string_view s, CharSet const& allowed, pct_encode_opts const& opt = {});
This function applies percent-encoding to the given plain string, by escaping all characters that are not in the specified CharSet. The output is written to the destination, and will be truncated if there is insufficient space.
char *dest = new char[MAX_LENGTH]; std::size_t encoded_size = pct_encode( dest, dest + MAX_LENGTH, "Program Files", pct_encode_opts{}, pchars ); assert( encoded_size == 15 ); assert( strncmp( "Program%20Files", dest, encoded_size ) == 0 );
Throws nothing.
true
if the output was large
enough to hold the entire result.
Name |
Description |
---|---|
|
A pointer to the beginning of the output buffer. Upon return, the argument will be changed to one past the last character written. |
|
A pointer to one past the end of the output buffer. |
|
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_bytes
.
Convenience header <boost/url.hpp>