Validate a percent encoded string and return the number of decoded bytes.
Defined in header <boost/url/pct_encoding.hpp>
result< std::size_t > validate_pct_encoding( string_view s, pct_decode_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 decoded using the given options. No encoding is actually performed. This function does not perform checking to ensure that the unencoded characters belong to specified character set.
This validates and calculates the decoded length of a valid percent-encoded string.
error_code ec; std::size_t decoded_size = validate_pct_encoding( "Program%20Files", ec, pct_decode_opts{} ); assert( ! ec.failed() ); assert( decoded_size == 13 );
This shows how validation can fail using an error code.
error_code ec; std::size_t decoded_size = validate_pct_encoding( "bad%escape", ec, pct_decode_opts{} ); assert( ec.failed() );
Throws nothing.
The number of bytes needed, excluding any null terminator.
Name |
Description |
---|---|
|
The percent-encoded string to analyze. |
|
The options for decoding. If this parameter is omitted, the default options will be used. |
pct_decode
,
pct_decode_bytes_unchecked
, pct_decode_opts
,
pct_decode_unchecked
,
Convenience header <boost/url.hpp>