# okpyeon (옥편)
[](https://crates.io/crates/okpyeon)
[](https://docs.rs/okpyeon)
한국어 입력기의 한자 키가 필요로 하는 두 가지 정적 후보 데이터: 독음 → 한자
후보(훈음 포함), 그리고 MS IME 식 자음 → 특수문자 표 (`ㅁ` + 한자 → `※ ☆ ★ …`).
Static candidate data for Korean IMEs, covering both things the 한자(hanja)
key does: **hanja lookup** (a hangul syllable reading to hanja candidates with
hun-eum glosses, like a paper 옥편) and the **MS-IME-style special symbol
tables** (compose a lone consonant, press the hanja key, pick a symbol).
Single-`char` lookups only; word-level conversion is deliberately out of
scope. No allocation, `no_std`, zero dependencies.
## Usage
```rust
// 독음 → 한자 후보 (훈음 포함, 상용 한자 우선 순서)
let candidates = okpyeon::hanja('학').unwrap();
assert_eq!(candidates[0], ('學', "배울 학"));
// 자음 → 특수문자 (MS IME 원본 표)
let shapes = okpyeon::symbols('ㅁ').unwrap();
assert!(shapes.contains(&'※'));
// 알려진 결함 2건을 보정한 표 (날개셋 / 최신 Windows 동작)
assert_eq!(okpyeon::symbols_revised('ㄹ').unwrap()[3], '°');
assert_eq!(okpyeon::symbols_revised('ㅁ').unwrap().last(), Some(&'㉾'));
```
The symbol tables define 18 keys, matching Windows MS IME: `ㄱ` punctuation,
`ㄴ` brackets, `ㄷ` math, `ㄹ` units, `ㅁ` general symbols, `ㅂ` box drawing,
`ㅅ`/`ㅇ` enclosed hangul/latin, `ㅈ` fullwidth digits, `ㅊ` fractions,
`ㅋ`/`ㅌ` modern/archaic jamo, `ㅍ` fullwidth latin, `ㅎ` greek, `ㄲ` extended
latin, `ㄸ` hiragana, `ㅃ` katakana, `ㅆ` cyrillic. `ㅉ` has no assignment,
faithful to MS IME.
## Data provenance
Both tables are vendored in `data/` from [libhangul] (commit `a34aef7`) and
compiled into sorted static slices by `build.rs`:
- `data/hanja.txt` — libhangul's `data/hanja/hanja.txt`, filtered to entries
whose key and value are each a single character (multi-syllable word
entries plus two anomalous multi-character-value entries removed; run
`scripts/update-data.sh` to regenerate). Candidate order preserves the file
order, which libhangul curates common-first, so it is directly usable as an
IME candidate list. libhangul's separate frequency file (`freq-hanja.txt`,
unclear licensing) is **not** used.
- `data/mssymbol.txt` — libhangul's `data/hanja/mssymbol.txt`, verbatim.
[`symbols`] is faithful to it, including two known quirks inherited from
old MS IME: `ㄹ`'s 4th slot is a fullwidth `F` (a duplicate of the one in
the `ㅍ` fullwidth-latin table) where `°` is expected, and `㉾` is missing.
[`symbols_revised`] corrects both, matching the 날개셋 input method and
current Windows respectively.
[libhangul]: https://github.com/libhangul/libhangul
[`symbols`]: https://docs.rs/okpyeon/latest/okpyeon/fn.symbols.html
[`symbols_revised`]: https://docs.rs/okpyeon/latest/okpyeon/fn.symbols_revised.html
## License
The crate's own code is dual-licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
- MIT license ([LICENSE-MIT](LICENSE-MIT))
at your option.
The vendored data files (`data/hanja.txt`, `data/mssymbol.txt`) are from
libhangul, copyright (c) Choe Hwanjin, licensed under the BSD 3-Clause
license; each file retains its original copyright and license header. The
compiled crate therefore contains BSD-3-Clause-licensed data
(SPDX: `(MIT OR Apache-2.0) AND BSD-3-Clause`).