<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="URLs use special characters to indicate the parts of the request. For example, a `?` question mark marks the end of a path and the start of a query string. In order for that character to exist inside a path, it needs to be encoded differently."><title>percent_encoding - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-dd39b87e5fcfba68.css"><metaname="rustdoc-vars"data-root-path="../"data-static-root-path="../static.files/"data-current-crate="percent_encoding"data-themes=""data-resource-suffix=""data-rustdoc-version="1.80.0 (051478957 2024-07-21)"data-channel="1.80.0"data-search-js="search-d52510db62a78183.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-118b08c4c78b968e.js"></script><scriptdefersrc="../crates.js"></script><scriptdefersrc="../static.files/main-20a3ad099b048cf2.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-df360f571f6edeae.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle"title="show sidebar"></button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../percent_encoding/index.html">percent_encoding</a><spanclass="version">2.3.1</span></h2></div><divclass="sidebar-elems"><ulclass="block"><li><aid="all-types"href="all.html">All Items</a></li></ul><section><ulclass="block"><li><ahref="#structs">Structs</a></li><li><ahref="#constants">Constants</a></li><li><ahref="#functions">Functions</a></li></ul></section></div></nav><divclass="sidebar-resizer"></div><main><divclass="width-limiter"><rustdoc-search></rustdoc-search><sectionid="main-content"class="content"><divclass="main-heading"><h1>Crate <aclass="mod"href="#">percent_encoding</a><buttonid="copy-path"title="Copy item path to clipboard">Copy item path</button></h1><spanclass="out-of-band"><aclass="src"href="../src/percent_encoding/lib.rs.html#9-477">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>URLs use special characters to indicate the parts of the request.
For example, a <code>?</code> question mark marks the end of a path and the start of a query string.
In order for that character to exist inside a path, it needs to be encoded differently.</p>
<p>Percent encoding replaces reserved characters with the <code>%</code> escape character
followed by a byte value as two hexadecimal digits.
For example, an ASCII space is replaced with <code>%20</code>.</p>
<p>When encoding, the set of characters that can (and should, for readability) be left alone
depends on the context.
The <code>?</code> question mark mentioned above is not a separator when used literally
inside of a query string, and therefore does not need to be encoded.
The <ahref="struct.AsciiSet.html"title="struct percent_encoding::AsciiSet"><code>AsciiSet</code></a> parameter of <ahref="fn.percent_encode.html"title="fn percent_encoding::percent_encode"><code>percent_encode</code></a> and <ahref="fn.utf8_percent_encode.html"title="fn percent_encoding::utf8_percent_encode"><code>utf8_percent_encode</code></a>
lets callers configure this.</p>
<p>This crate deliberately does not provide many different sets.
Users should consider in what context the encoded string will be used,
read relevant specifications, and define their own set.
This is done by using the <code>add</code> method of an existing set.</p>
</div></details><h2id="structs"class="section-header">Structs<ahref="#structs"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="struct"href="struct.AsciiSet.html"title="struct percent_encoding::AsciiSet">AsciiSet</a></div><divclass="desc docblock-short">Represents a set of characters or bytes in the ASCII range.</div></li><li><divclass="item-name"><aclass="struct"href="struct.PercentDecode.html"title="struct percent_encoding::PercentDecode">PercentDecode</a></div><divclass="desc docblock-short">The return type of <ahref="fn.percent_decode.html"title="fn percent_encoding::percent_decode"><code>percent_decode</code></a>.</div></li><li><divclass="item-name"><aclass="struct"href="struct.PercentEncode.html"title="struct percent_encoding::PercentEncode">PercentEncode</a></div><divclass="desc docblock-short">The return type of <ahref="fn.percent_encode.html"title="fn percent_encoding::percent_encode"><code>percent_encode</code></a> and <ahref="fn.utf8_percent_encode.html"title="fn percent_encoding::utf8_percent_encode"><code>utf8_percent_encode</code></a>.</div></li></ul><h2id="constants"class="section-header">Constants<ahref="#constants"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="constant"href="constant.CONTROLS.html"title="constant percent_encoding::CONTROLS">CONTROLS</a></div><divclass="desc docblock-short">The set of 0x00to 0x1F (C0 controls), and 0x7F (DEL).</div></li><li><divclass="item-name"><aclass="constant"href="constant.NON_ALPHANUMERIC.html"title="constant percent_encoding::NON_ALPHANUMERIC">NON_ALPHANUMERIC</a></div><divclass="desc docblock-short">Everything that is not an ASCII letter or digit.</div></li></ul><h2id="functions"class="section-header">Functions<ahref="#functions"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="fn"href="fn.percent_decode.html"title="fn percent_encoding::percent_decode">percent_decode</a></div><divclass="desc docblock-short">Percent-decode the given bytes.</div></li><li><divclass="item-name"><aclass="fn"href="fn.percent_decode_str.html"title="fn percent_encoding::percent_decode_str">percent_decode_str</a></div><divclass="desc docblock-short">Percent-decode the given string.</div></li><li><divclass="item-name"><aclass="fn"href="fn.percent_encode.html"title="fn percent_encoding::percent_encode">percent_encode</a></div><divclass="desc docblock-short">Percent-encode the given bytes with the given set.</div></li><li><divclass="item-name"><aclass="fn"href="fn.percent_encode_byte.html"title="fn percent_encoding::percent_encode_byte">percent_encode_byte</a></div><divclass="desc docblock-short">Return the percent-encoding of the given byte.</div></li><li><divclass="item-name"><aclass="fn"href="fn.utf8_percent_encode.html"title="fn percent_encoding::utf8_percent_encode">utf8_percent_encode</a></div><divclass="desc docblock-short">Percent-encode the UTF-8 encoding of the given string.</div></li></ul></section></div></main></body></html>