<!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><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-5bc39a1768837dd0.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.77.1 (7cf61ebde 2024-03-27)"data-channel="1.77.1"data-search-js="search-dd67cee4cfa65049.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-4c98445ec4002617.js"></script><scriptdefersrc="../crates.js"></script><scriptdefersrc="../static.files/main-48f368f3872407c8.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-04d5337699b92874.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><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">
<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../percent_encoding/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><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"><imgsrc="../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="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>