[#boost-urls-encode-0d]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::encode
:relfileprefix: ../../
:mrdocs:

`encode` overloads

== Synopses

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/encode.hpp#L119[boost&sol;url&sol;encode&period;hpp]&gt;`

Return a percent&hyphen;encoded string


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:boost/urls/string_token.adoc[string&lowbar;token]::xref:boost/urls/string_token/StringToken.adoc[StringToken] StringToken = xref:boost/urls/string_token.adoc[string&lowbar;token]::xref:boost/urls/string_token/return_string.adoc[return&lowbar;string],
    xref:boost/urls/grammar.adoc[grammar]::xref:boost/urls/grammar/CharSet.adoc[CharSet] CS&gt;
StringToken::result&lowbar;type
xref:boost/urls/encode-04.adoc[encode](
    core::string&lowbar;view s,
    CS const& unreserved,
    xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts] opt = &lcub;&rcub;,
    StringToken&& token = &lcub;&rcub;) noexcept;
----

[.small]#xref:boost/urls/encode-04.adoc[_» more&period;&period;&period;_]#

Apply percent&hyphen;encoding to a string


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:boost/urls/grammar.adoc[grammar]::xref:boost/urls/grammar/CharSet.adoc[CharSet] CS&gt;
std::size&lowbar;t
xref:boost/urls/encode-09.adoc[encode](
    char* dest,
    std::size&lowbar;t size,
    core::string&lowbar;view s,
    CS const& unreserved,
    xref:boost/urls/encoding_opts.adoc[encoding&lowbar;opts] opt = &lcub;&rcub;);
----

[.small]#xref:boost/urls/encode-09.adoc[_» more&period;&period;&period;_]#

== Return Value

* The string
* The number of characters written to the destination buffer&period;

== Parameters

[cols=2]
|===
| Name
| Description
| *s*
| The string to encode&period;
| *unreserved*
| The set of characters that is not percent&hyphen;encoded&period;
| *opt*
| The options for encoding&period; If this parameter is omitted, the default options are used&period;
| *token*
| A string token&period;
| *dest*
| The destination buffer to write to&period;
| *size*
| The number of writable characters pointed to by `dest`&period; If this is less than `encoded&lowbar;size(s)`, the result is truncated&period;
|===

== See Also

xref:boost/urls/encode-04.adoc[`encode`], xref:boost/urls/encoded_size.adoc[`encoded&lowbar;size`], xref:boost/urls/encoding_opts.adoc[`encoding&lowbar;opts`],

xref:boost/urls/encode-04.adoc[`encode`], xref:boost/urls/encoded_size.adoc[`encoded&lowbar;size`], xref:boost/urls/make_pct_string_view.adoc[`make&lowbar;pct&lowbar;string&lowbar;view`]&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
