<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `codepage_437` crate."><meta name="keywords" content="rust, rustlang, rust-lang, codepage_437"><title>codepage_437 - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><p class='location'>Crate codepage_437</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all codepage_437's items</p></a><div class="block items"><ul><li><a href="#structs">Structs</a></li><li><a href="#statics">Statics</a></li><li><a href="#traits">Traits</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'codepage_437', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/codepage_437/lib.rs.html#1-97' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>codepage_437</a></span></h1><div class='docblock'><p>Conversion to and from codepage 437.</p> <p>Use the <code>{Borrow,}FromCp437</code> traits to convert series of cp437 bytes to Unicode, and the <code>cp437_to_unicode()</code> function to decode a single codepoint.</p> <p>Use the <code>{Into,To}Cp437</code> traits to convert Unicode to a series of cp437 bytes, and the <code>unicode_to_cp437()</code> function to encode a single codepoint.</p> <h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1> <p>Borrowing from a buffer:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="kw-2">&</span>[<span class="comment">/* buffer acquired somewhere */</span>]; <span class="doccomment">/// in_unicode will be Cow::Borrowed if data only contains overlapping characters,</span> <span class="doccomment">/// or Cow::Owned if a conversion needed to have been made.</span> <span class="kw">let</span> <span class="ident">in_unicode</span> <span class="op">=</span> <span class="ident">Cow</span>::<span class="ident">borrow_from_cp437</span>(<span class="ident">data</span>, <span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>); <span class="comment">// Also valid:</span> <span class="kw">let</span> <span class="ident">in_unicode</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">borrow_from_cp437</span>(<span class="ident">data</span>, <span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>);</pre> <p>Moving out of a buffer:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="comment">/* buffer moved in from somewhere */</span>]; <span class="doccomment">/// data is moved out of and zero-alloced into in_unicode</span> <span class="doccomment">/// if it only contains overlapping characters</span> <span class="kw">let</span> <span class="ident">in_unicode</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from_cp437</span>(<span class="ident">data</span>, <span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>);</pre> <p>Borrowing from a <code>&str</code>:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="string">"Some string."</span>; <span class="doccomment">/// in_cp437 will be Cow::Borrowed if data only contains overlapping characters,</span> <span class="doccomment">/// Cow::Owned if a conversion needed to have been made,</span> <span class="doccomment">/// or Err, if data can't be represented as cp437</span> <span class="kw">let</span> <span class="ident">in_cp437</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">to_cp437</span>(<span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>); <span class="comment">// Also valid (String is AsRef<str>):</span> <span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="string">"Some string."</span>.<span class="ident">to_string</span>(); <span class="kw">let</span> <span class="ident">in_cp437</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">to_cp437</span>(<span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>);</pre> <p>Moving out of a <code>String</code>:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="string">"Some string."</span>.<span class="ident">to_string</span>(); <span class="doccomment">/// data is moved out of and zero-alloced into in_cp437</span> <span class="doccomment">/// if it only contains overlapping characters</span> <span class="kw">let</span> <span class="ident">in_cp437</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">into_cp437</span>(<span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>);</pre> <p>Unrepresentable Unicode:</p> <pre class="rust rust-example-rendered"> <span class="comment">// Ż has no representation in cp437</span> <span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="string">"Jurek żelaznym żurkiem żre żupan."</span>; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">to_cp437</span>(<span class="kw-2">&</span><span class="ident">CP437_CONTROL</span>); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>()); <span class="comment">// result.unwrap_err() is Cp437Error (or IntoCp437Error for into_cp437()),</span> <span class="comment">// with an API modeled after libstd's {From,}Utf8Error</span></pre> </div><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2> <table> <tr class=' module-item'> <td><a class="struct" href="struct.Cp437Dialect.html" title='struct codepage_437::Cp437Dialect'>Cp437Dialect</a></td> <td class='docblock-short'> <p>Specifier for the specific kind of cp437.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.Cp437Error.html" title='struct codepage_437::Cp437Error'>Cp437Error</a></td> <td class='docblock-short'> <p>Errors which can occur when attempting to interpret a string as a sequence of cp437 codepoints.</p> </td> </tr> <tr class=' module-item'> <td><a class="struct" href="struct.IntoCp437Error.html" title='struct codepage_437::IntoCp437Error'>IntoCp437Error</a></td> <td class='docblock-short'> <p>A possible error value when converting a <code>String</code> into a cp437 byte vector.</p> </td> </tr></table><h2 id='statics' class='section-header'><a href="#statics">Statics</a></h2> <table> <tr class=' module-item'> <td><a class="static" href="static.CP437_WINGDINGS.html" title='static codepage_437::CP437_WINGDINGS'>CP437_WINGDINGS</a></td> <td class='docblock-short'> <p>cp437 <a href="https://en.wikipedia.org/wiki/Code_page_437#Character_set">with wingdings</a>, as seen on Wikipedia.</p> </td> </tr> <tr class=' module-item'> <td><a class="static" href="static.CP437_CONTROL.html" title='static codepage_437::CP437_CONTROL'>CP437_CONTROL</a></td> <td class='docblock-short'> <p><a href="http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT"><code>cp437_DOSLatinUS</code></a> as provided by the Unicode Consortium.</p> </td> </tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2> <table> <tr class=' module-item'> <td><a class="trait" href="trait.BorrowFromCp437.html" title='trait codepage_437::BorrowFromCp437'>BorrowFromCp437</a></td> <td class='docblock-short'> <p>Try to borrow data encoded in cp437 as a Unicode container of the specified type.</p> </td> </tr> <tr class=' module-item'> <td><a class="trait" href="trait.FromCp437.html" title='trait codepage_437::FromCp437'>FromCp437</a></td> <td class='docblock-short'> <p>Move data encoded in cp437 to a Unicode container of the specified type.</p> </td> </tr> <tr class=' module-item'> <td><a class="trait" href="trait.IntoCp437.html" title='trait codepage_437::IntoCp437'>IntoCp437</a></td> <td class='docblock-short'> <p>Move Unicode data to a container of cp437 data.</p> </td> </tr> <tr class=' module-item'> <td><a class="trait" href="trait.ToCp437.html" title='trait codepage_437::ToCp437'>ToCp437</a></td> <td class='docblock-short'> <p>Borrow (if possible) Unicode data as cp437 data.</p> </td> </tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "codepage_437";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>