37 lines
10 KiB
HTML
37 lines
10 KiB
HTML
<!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="Parsing, manipulating, and serializing Unicode Language and Locale Identifiers."><title>icu_locale_core - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="icu_locale_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Crate icu_locale_core</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../icu_locale_core/index.html">icu_<wbr>locale_<wbr>core</a><span class="version">2.1.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>icu_<wbr>locale_<wbr>core</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/icu_locale_core/lib.rs.html#5-96">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Parsing, manipulating, and serializing Unicode Language and Locale Identifiers.</p>
|
|
<p>This module is published as its own crate (<a href="https://docs.rs/icu_locale_core/latest/icu_locale_core/"><code>icu_locale_core</code></a>)
|
|
and as part of the <a href="https://docs.rs/icu/latest/icu/"><code>icu</code></a> crate. See the latter for more details on the ICU4X project.</p>
|
|
<p>The module provides algorithms for parsing a string into a well-formed language or locale identifier
|
|
as defined by <a href="https://unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers"><code>UTS #35: Unicode LDML 3. Unicode Language and Locale Identifiers</code></a>. Additionally
|
|
the module provides <a href="preferences/index.html" title="mod icu_locale_core::preferences"><code>preferences</code></a> interface for operations on locale preferences and conversions
|
|
from and to locale unicode extensions.</p>
|
|
<p><a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a> is the most common structure to use for storing information about a language,
|
|
script, region, variants and extensions. In almost all cases, this struct should be used as the
|
|
base unit for all locale management operations.</p>
|
|
<p><a href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier"><code>LanguageIdentifier</code></a> is a strict subset of <a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a> which can be useful in a narrow range of
|
|
cases where <a href="extensions/index.html" title="mod icu_locale_core::extensions"><code>Unicode Extensions</code></a> are not relevant.</p>
|
|
<p>If in doubt, use <a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a>.</p>
|
|
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>icu::locale::Locale;
|
|
<span class="kw">use </span>icu::locale::{
|
|
locale,
|
|
subtags::{language, region},
|
|
};
|
|
|
|
<span class="kw">let </span><span class="kw-2">mut </span>loc: Locale = <span class="macro">locale!</span>(<span class="string">"en-US"</span>);
|
|
|
|
<span class="macro">assert_eq!</span>(loc.id.language, <span class="macro">language!</span>(<span class="string">"en"</span>));
|
|
<span class="macro">assert_eq!</span>(loc.id.script, <span class="prelude-val">None</span>);
|
|
<span class="macro">assert_eq!</span>(loc.id.region, <span class="prelude-val">Some</span>(<span class="macro">region!</span>(<span class="string">"US"</span>)));
|
|
<span class="macro">assert_eq!</span>(loc.id.variants.len(), <span class="number">0</span>);
|
|
|
|
loc.id.region = <span class="prelude-val">Some</span>(<span class="macro">region!</span>(<span class="string">"GB"</span>));
|
|
|
|
<span class="macro">assert_eq!</span>(loc, <span class="macro">locale!</span>(<span class="string">"en-GB"</span>));</code></pre></div>
|
|
<p>For more details, see <a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a> and <a href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier"><code>LanguageIdentifier</code></a>.</p>
|
|
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="extensions/index.html" title="mod icu_locale_core::extensions">extensions</a></dt><dd>Unicode Extensions provide a mechanism to extend the <a href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier"><code>LanguageIdentifier</code></a> with
|
|
additional bits of information - a combination of a <a href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier"><code>LanguageIdentifier</code></a> and <a href="extensions/struct.Extensions.html" title="struct icu_locale_core::extensions::Extensions"><code>Extensions</code></a>
|
|
is called <a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a>.</dd><dt><a class="mod" href="preferences/index.html" title="mod icu_locale_core::preferences">preferences</a></dt><dd>This API provides necessary functionality for building user preferences structs.</dd><dt><a class="mod" href="subtags/index.html" title="mod icu_locale_core::subtags">subtags</a></dt><dd>Language Identifier and Locale contains a set of subtags
|
|
which represent different fields of the structure.</dd><dt><a class="mod" href="zerovec/index.html" title="mod icu_locale_core::zerovec">zerovec</a></dt><dd>Documentation on zero-copy deserialization of locale types.</dd></dl><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro.langid.html" title="macro icu_locale_core::langid">langid</a></dt><dd>A macro allowing for compile-time construction of valid <a href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier"><code>LanguageIdentifier</code></a>s.</dd><dt><a class="macro" href="macro.locale.html" title="macro icu_locale_core::locale">locale</a></dt><dd>A macro allowing for compile-time construction of valid <a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a>s.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.DataLocale.html" title="struct icu_locale_core::DataLocale">Data<wbr>Locale</a></dt><dd>A locale type optimized for use in fallbacking and the ICU4X data pipeline.</dd><dt><a class="struct" href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier">Language<wbr>Identifier</a></dt><dd>A core struct representing a <a href="https://unicode.org/reports/tr35/tr35.html#Unicode_language_identifier"><code>Unicode BCP47 Language Identifier</code></a>.</dd><dt><a class="struct" href="struct.Locale.html" title="struct icu_locale_core::Locale">Locale</a></dt><dd>A core struct representing a <a href="https://unicode.org/reports/tr35/tr35.html#Unicode_locale_identifier"><code>Unicode Locale Identifier</code></a>.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.ParseError.html" title="enum icu_locale_core::ParseError">Parse<wbr>Error</a></dt><dd>List of parser errors that can be generated
|
|
while parsing <a href="struct.LanguageIdentifier.html" title="struct icu_locale_core::LanguageIdentifier"><code>LanguageIdentifier</code></a>, <a href="struct.Locale.html" title="struct icu_locale_core::Locale"><code>Locale</code></a>,
|
|
<a href="subtags/index.html" title="mod icu_locale_core::subtags"><code>subtags</code></a> or <a href="extensions/index.html" title="mod icu_locale_core::extensions"><code>extensions</code></a>.</dd></dl></section></div></main></body></html> |