hangeul 0.4.0

Korean alphabet manipulation library
Documentation
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="pandoc" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
  <title>README</title>
  <style>
      code{white-space: pre-wrap;}
      span.smallcaps{font-variant: small-caps;}
      span.underline{text-decoration: underline;}
      div.column{display: inline-block; vertical-align: top; width: 50%;}
  </style>
  <style>
code.sourceCode > span { display: inline-block; line-height: 1.25; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
code.sourceCode { white-space: pre-wrap; }
code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
  </style>
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  <![endif]-->
</head>
<body>
<h1 id="hangeul-rs">hangeul-rs</h1>
<p><a href="https://builds.sr.ht/~andrewzah/hangeul-rs?"><img src="https://builds.sr.ht/~andrewzah/hangeul-rs.svg" alt="builds.sr.ht status" /></a> <a href="https://docs.rs/hangeul"><img src="https://docs.rs/hangeul/badge.svg" alt="docs badge" /></a> <a href="https://crates.io/crates/hangeul"><img src="https://img.shields.io/crates/v/hangeul.svg" alt="crates version badge" /></a></p>
<p>A lightweight Korean alphabet manipulation library for Rust. No external crates are used.</p>
<p>Only modern, composable Korean unicode blocks are supported (<code>AC00</code><code>D7AF</code>, <code>1100</code><code>11FF</code>, <code>3130</code><code>318F</code>).</p>
<pre class="toml"><code>[dependencies]
hangeul = &quot;0.2.0&quot;</code></pre>
<h2 id="usage">Usage</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode rust"><code class="sourceCode rust"><span id="cb2-1"><a href="#cb2-1"></a><span class="kw">extern</span> <span class="kw">crate</span> hangeul;</span>
<span id="cb2-2"><a href="#cb2-2"></a></span>
<span id="cb2-3"><a href="#cb2-3"></a><span class="kw">fn</span> main() <span class="op">{</span></span>
<span id="cb2-4"><a href="#cb2-4"></a>    <span class="co">// literally: pikachu transliterated</span></span>
<span id="cb2-5"><a href="#cb2-5"></a>    <span class="kw">let</span> subject = <span class="st">&quot;피카츄&quot;</span>;</span>
<span id="cb2-6"><a href="#cb2-6"></a></span>
<span id="cb2-7"><a href="#cb2-7"></a>    <span class="co">// Korean marks the topic of the sentence with a post position</span></span>
<span id="cb2-8"><a href="#cb2-8"></a>    <span class="co">// particle: 이 follows consonants, and 가 follows vowels.</span></span>
<span id="cb2-9"><a href="#cb2-9"></a>    <span class="kw">let</span> post_position = <span class="kw">match</span> <span class="pp">hangeul::</span>ends_in_consonant(subject).unwrap() <span class="op">{</span></span>
<span id="cb2-10"><a href="#cb2-10"></a>        <span class="cn">true</span> =&gt; <span class="st">&quot;&quot;</span>,</span>
<span id="cb2-11"><a href="#cb2-11"></a>        <span class="cn">false</span> =&gt; <span class="st">&quot;&quot;</span></span>
<span id="cb2-12"><a href="#cb2-12"></a>    <span class="op">}</span>;</span>
<span id="cb2-13"><a href="#cb2-13"></a></span>
<span id="cb2-14"><a href="#cb2-14"></a>    <span class="co">// -&gt; A wild pikachu has appeared!</span></span>
<span id="cb2-15"><a href="#cb2-15"></a>    <span class="kw">let</span> sentence = <span class="pp">format!</span>(<span class="st">&quot;야생의 {}{} 나타났다!&quot;</span>, subject, post_position);</span>
<span id="cb2-16"><a href="#cb2-16"></a>    <span class="pp">println!</span>(<span class="st">&quot;{}&quot;</span>, sentence); <span class="co">// 야생의 피카츄가 나타났다!</span></span>
<span id="cb2-17"><a href="#cb2-17"></a></span>
<span id="cb2-18"><a href="#cb2-18"></a>    <span class="co">// get_lead is an alias of get_choseong, to get the first character</span></span>
<span id="cb2-19"><a href="#cb2-19"></a>    <span class="co">// of a Hangeul syllable.</span></span>
<span id="cb2-20"><a href="#cb2-20"></a>    <span class="kw">let</span> sentence_in_choseong = sentence.chars()</span>
<span id="cb2-21"><a href="#cb2-21"></a>                                .map(|c| <span class="pp">hangeul::</span>get_lead(&amp;c).unwrap_or(c))</span>
<span id="cb2-22"><a href="#cb2-22"></a>                                .<span class="pp">collect::</span>&lt;<span class="dt">String</span>&gt;();</span>
<span id="cb2-23"><a href="#cb2-23"></a></span>
<span id="cb2-24"><a href="#cb2-24"></a>    <span class="pp">println!</span>(<span class="st">&quot;{}&quot;</span>, sentence_in_choseong); <span class="co">// ㅇㅅㅇ ㅍㅋㅊㄱ ㄴㅌㄴㄷ!</span></span>
<span id="cb2-25"><a href="#cb2-25"></a><span class="op">}</span></span></code></pre></div>
<h2 id="examples">Examples</h2>
<p><a href="./examples">Examples</a>.</p>
<h2 id="documentation">Documentation</h2>
<p><a href="https://docs.rs/hangeul/">Docs.rs</a></p>
<h2 id="license">License</h2>
<p>Distributed under MIT License</p>
</body>
</html>