unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

ucd/hangul_syllable_type.mbt
1///|2/// Unicode Hangul_Syllable_Type values3/// See the Unicode Standard, section 3.12, Conjoining Jamo Behavior:4/// https://www.unicode.org/versions/latest/core-spec/chapter-3/#G246465#derive(Debug, Eq)6pub(all) enum HangulSyllableType {7  NotApplicable // NA8  LeadingJamo // L9  VowelJamo // V10  TrailingJamo // T11  LVSyllable // LV12  LVTSyllable // LVT13}1415///|16#deprecated("Use `Debug::to_repr` instead", skip_current_package=true)17#doc(hidden)18pub extend HangulSyllableType with Debug::{to_repr}1920///|21pub extend HangulSyllableType with Eq::{not_equal, equal}2223///|24pub extend HangulSyllableType with Show::{to_string, output}2526///|27pub impl Show for HangulSyllableType with fn output(self, logger) {28  match self {29    NotApplicable => logger.write_string("NotApplicable")30    LeadingJamo => logger.write_string("LeadingJamo")31    VowelJamo => logger.write_string("VowelJamo")32    TrailingJamo => logger.write_string("TrailingJamo")33    LVSyllable => logger.write_string("LVSyllable")34    LVTSyllable => logger.write_string("LVTSyllable")35  }36}3738///|39/// Convert a HangulSyllableType ordinal, below 6, to the enum value.40///41/// A constructor without arguments is its ordinal on every backend. A42/// `match` or a table would cost a jump table or a load on wasm, wasm-gc43/// and JS, slower there than the trie lookup itself.44fn ordinal_to_hangul_syllable_type(ordinal : Int32) -> HangulSyllableType = "%identity"4546///|47/// Get the Hangul_Syllable_Type for a character.48///49/// Hangul_Syllable_Type tells the conjoining jamo apart from the precomposed50/// syllables: a leading consonant, a vowel, a trailing consonant, a syllable51/// of a leading consonant and a vowel, or one that also has a trailing52/// consonant. Every other character, including the Hangul compatibility53/// jamo and unassigned code points, is NotApplicable.54///55/// It is narrower than Grapheme_Cluster_Break, whose V value also covers a56/// few characters outside Hangul.57pub fn hangul_syllable_type(c : Char) -> HangulSyllableType {58  ordinal_to_hangul_syllable_type(59    @hangul_syllable_type.lookup_hangul_syllable_type(c),60  )61}62