forked from bekker/hangeul-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.html
123 lines (123 loc) · 7.62 KB
/
readme.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!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 = "0.2.0"</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">"피카츄"</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> => <span class="st">"이"</span>,</span>
<span id="cb2-11"><a href="#cb2-11"></a> <span class="cn">false</span> => <span class="st">"가"</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">// -> 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">"야생의 {}{} 나타났다!"</span>, subject, post_position);</span>
<span id="cb2-16"><a href="#cb2-16"></a> <span class="pp">println!</span>(<span class="st">"{}"</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(&c).unwrap_or(c))</span>
<span id="cb2-22"><a href="#cb2-22"></a> .<span class="pp">collect::</span><<span class="dt">String</span>>();</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">"{}"</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>