:relfileprefix: ../../../ [#79B53D34FC61E5CE15C0301A400D425D159B48A9] = Function url_base::set_encoded_fragment pass:v,q[Set the fragment.] == Synopsis Declared in header `` [source,cpp,subs="verbatim,macros,-callouts"] ---- xref:boost/urls/url_base.adoc[url_base]& set_encoded_fragment(xref:boost/urls/pct_string_view.adoc[pct_string_view] s); ---- == Description pass:v,q[This function sets the fragment to the] pass:v,q[specified string, which may contain] pass:v,q[percent-escapes and which may be empty.] pass:v,q[An empty fragment is distinct from] pass:v,q[having no fragment.] pass:v,q[Escapes in the string are preserved,] pass:v,q[and reserved characters in the string] pass:v,q[are percent-escaped in the result.] === Example [,cpp] ---- assert( url("?first=john&last=doe" ).set_encoded_fragment( "john%2Ddoe" ).fragment() == "john-doe" ); ---- === Postconditions [,cpp] ---- this->has_fragment() == true && this->fragment() == decode_view( s ) ---- === Complexity pass:v,q[Linear in `this->size() + s.size()`.] === Exception Safety pass:v,q[Strong guarantee.] pass:v,q[Calls to allocate may throw.] pass:v,q[Exceptions thrown on invalid input.] === BNF [,cpp] ---- fragment = *( pchar / "/" / "?" ) ---- === Specification * link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5[3.5. Fragment] == Return Value * `` == Parameters |=== | Name | Type | *s* | `pct_string_view` |===