:relfileprefix: ../../
[#boost-urls-encoded_size]

= xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::encoded_size


Return the buffer size needed for percent-encoding


== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/encode.hpp#L62[boost/url/encode.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<class CharSet>
xref:std.adoc[std]::size_t
encoded_size(
    core::string_view s,
    CharSet const& unreserved,
    xref:boost/urls/encoding_opts.adoc[encoding_opts] opt = = {}) noexcept;
----

== Description


This function returns the exact number
of bytes necessary to store the result
of applying percent-encoding to the
string using the given options and
character set.
No encoding is actually performed.

=== Example
[,cpp]
----
assert( encoded_size( "My Stuff", pchars ) == 10 );
----

=== Exception Safety

Throws nothing.

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-2.1[2.1. Percent-Encoding (rfc3986)]




== Return Value


The number of bytes needed,
excluding any null terminator.



== Parameters

|===
| Name | Description 

| *s*
| 
The string to measure.

| *unreserved*
| 
The set of characters
that is not percent-encoded.

| *opt*
| 
The options for encoding. If
this parameter is omitted, the default
options are be used.

|===




== See Also


xref:boost/urls/encode-04.adoc[encode]
,
xref:boost/urls/encoding_opts.adoc[encoding_opts]
,
xref:boost/urls/make_pct_string_view.adoc[make_pct_string_view]
.



