[#boost-urls-url_view_base-encoded_fragment]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url&lowbar;view&lowbar;base]::encoded&lowbar;fragment
:relfileprefix: ../../../
:mrdocs:


Return the fragment

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L2156[boost&sol;url&sol;url&lowbar;view&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/pct_string_view.adoc[pct&lowbar;string&lowbar;view]
encoded&lowbar;fragment() const noexcept;
----

== Description


This function returns the fragment as a        string with percent&hyphen;escapes&period;        Ownership is not transferred&semi; the        string returned references the underlying        character buffer, which must remain valid        or else undefined behavior occurs&period;


=== Example

[,cpp]
----
assert( url_view( "http://www.example.com/index.htm#a%2D1" ).encoded_fragment() == "a%2D1" );
----

=== Complexity

Constant&period;


=== Exception Safety

Throws nothing&period;


=== BNF

[,cpp]
----
fragment        = *( pchar / "/" / "?" )

pchar           = unreserved / pct-encoded / sub-delims / ":" / "@"
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5[3&period;5&period; Fragment (rfc3986)]

Return the fragment

This function returns the fragment as a        string with percent&hyphen;escapes&period;        Ownership is not transferred&semi; the        string returned references the underlying        character buffer, which must remain valid        or else undefined behavior occurs&period;


=== Example

[,cpp]
----
assert( url_view( "http://www.example.com/index.htm#a%2D1" ).encoded_fragment() == "a%2D1" );
----

=== Complexity

Constant&period;


=== Exception Safety

Throws nothing&period;


=== BNF

[,cpp]
----
fragment        = *( pchar / "/" / "?" )

pchar           = unreserved / pct-encoded / sub-delims / ":" / "@"
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5[3&period;5&period; Fragment (rfc3986)]



== See Also


xref:boost/urls/url_view_base/fragment.adoc[fragment],            xref:boost/urls/url_view_base/has_fragment.adoc[has&lowbar;fragment]&period;



xref:boost/urls/url_view_base/fragment.adoc[fragment],            xref:boost/urls/url_view_base/has_fragment.adoc[has&lowbar;fragment]&period;






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