<!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="Determine displayed width of `char` and `str` types according to Unicode Standard Annex #11 and other portions of the Unicode standard. See the Rules for determining width section for the exact rules."><title>unicode_width - 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="unicode_width"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="icon"href="https://unicode-rs.github.io/unicode-rs_sm.png"></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><aclass="logo-container"href="../unicode_width/index.html"><imgsrc="https://unicode-rs.github.io/unicode-rs_sm.png"alt=""></a></nav><navclass="sidebar"><divclass="sidebar-crate"><aclass="logo-container"href="../unicode_width/index.html"><imgsrc="https://unicode-rs.github.io/unicode-rs_sm.png"alt="logo"></a><h2><ahref="../unicode_width/index.html">unicode_width</a><spanclass="version">0.1.13</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="#constants">Constants</a></li><li><ahref="#traits">Traits</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="#">unicode_width</a><buttonid="copy-path"title="Copy item path to clipboard">Copy item path</button></h1><spanclass="out-of-band"><aclass="src"href="../src/unicode_width/lib.rs.html#11-265">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>Determine displayed width of <code>char</code> and <code>str</code> types according to
<ahref="http://www.unicode.org/reports/tr11/">Unicode Standard Annex #11</a>
<li><ahref="https://unicode.org/reports/tr51/#def_emoji_presentation_sequence">Emoji presentation sequences</a> have width 2.</li>
<li>Outside of an East Asian context, <ahref="https://unicode.org/reports/tr51/#def_text_presentation_sequence">text presentation sequences</a> have width 1
if their base character:
<ul>
<li>Has the <ahref="https://unicode.org/reports/tr51/#def_emoji_presentation"><code>Emoji_Presentation</code></a> property, and</li>
<li>Is not in the <ahref="https://unicode.org/charts/nameslist/n_1F200.html">Enclosed Ideographic Supplement</a> block.</li>
</ul>
</li>
<li>The sequence <code>"\r\n"</code> has width 1.</li>
<li><ahref="https://www.unicode.org/versions/Unicode15.0.0/ch18.pdf#G42078">Lisu tone letter</a> combinations consisting of a character in the range <code>'\u{A4F8}'..='\u{A4FB}'</code>
followed by a character in the range <code>'\u{A4FC}'..='\u{A4FD}'</code> have width 1.</li>
<li>In an East Asian context only, <code><</code>, <code>=</code>, or <code>></code> have width 2 when followed by <ahref="https://util.unicode.org/UnicodeJsps/character.jsp?a=0338"><code>'\u{0338}'</code> COMBINING LONG SOLIDUS OVERLAY</a>.</li>
<li>The following 8 characters, all of which have NFD decompositions consisting of two <ahref="https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G52443"><code>Grapheme_Extend</code></a> characters:
with a <ahref="https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf#G45593"><code>Hangul_Syllable_Type</code></a> of <code>Vowel_Jamo</code> (<code>V</code>) or <code>Trailing_Jamo</code> (<code>T</code>).</li>
<li>The following <ahref="https://www.unicode.org/versions/Unicode15.0.0/ch23.pdf#G37908"><code>Prepended_Concatenation_Mark</code></a>s:
<ul>
<li><ahref="https://util.unicode.org/UnicodeJsps/character.jsp?a=0605"><code>'\u{0605}'</code> NUMBER MARK ABOVE</a>,</li>
with an <ahref="https://www.unicode.org/reports/tr11/#ED1"><code>East_Asian_Width</code></a> of <ahref="https://www.unicode.org/reports/tr11/#ED2"><code>Fullwidth</code></a> or <ahref="https://www.unicode.org/reports/tr11/#ED4"><code>Wide</code></a> have width 2.</li>
<li>Characters fulfilling all of the following conditions have width 2 in an East Asian context, and width 1 otherwise:
<ul>
<li>Has an <ahref="https://www.unicode.org/reports/tr11/#ED1"><code>East_Asian_Width</code></a> of <ahref="https://www.unicode.org/reports/tr11/#ED6"><code>Ambiguous</code></a>, or
has a canonical decomposition to an <ahref="https://www.unicode.org/reports/tr11/#ED6"><code>Ambiguous</code></a> character followed by <ahref="https://util.unicode.org/UnicodeJsps/character.jsp?a=0338"><code>'\u{0338}'</code> COMBINING LONG SOLIDUS OVERLAY</a>, or
is <ahref="https://util.unicode.org/UnicodeJsps/character.jsp?a=0387"><code>'\u{0387}'</code> GREEK ANO TELEIA</a>, and</li>
<li>Does not have a <ahref="https://www.unicode.org/versions/Unicode15.0.0/ch04.pdf#G124142"><code>General_Category</code></a> of <code>Modifier_Symbol</code>, and</li>
<li>Does not have a <ahref="https://www.unicode.org/reports/tr24/#Script"><code>Script</code></a> of <code>Latin</code>, <code>Greek</code>, or <code>Cyrillic</code>, or is a Roman numeral in the range <code>'\u{2160}'..='\u{217F}'</code>.</li>
</div></details><h2id="constants"class="section-header">Constants<ahref="#constants"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="constant"href="constant.UNICODE_VERSION.html"title="constant unicode_width::UNICODE_VERSION">UNICODE_VERSION</a></div><divclass="desc docblock-short">The version of <ahref="http://www.unicode.org/">Unicode</a>
that this version of unicode-width is based on.</div></li></ul><h2id="traits"class="section-header">Traits<ahref="#traits"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="trait"href="trait.UnicodeWidthChar.html"title="trait unicode_width::UnicodeWidthChar">UnicodeWidthChar</a></div><divclass="desc docblock-short">Methods for determining displayed width of Unicode characters.</div></li><li><divclass="item-name"><aclass="trait"href="trait.UnicodeWidthStr.html"title="trait unicode_width::UnicodeWidthStr">UnicodeWidthStr</a></div><divclass="desc docblock-short">Methods for determining displayed width of Unicode strings.</div></li></ul></section></div></main></body></html>