unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

ucd/joining_type.mbt
1///|2/// Unicode Joining_Type values3/// See the Unicode Standard, section 9.2, Arabic:4/// https://www.unicode.org/versions/latest/core-spec/chapter-9/#G74805#derive(Debug, Eq)6pub(all) enum JoiningType {7  NonJoining // U8  JoinCausing // C9  DualJoining // D10  LeftJoining // L11  RightJoining // R12  Transparent // T13}1415///|16#deprecated("Use `Debug::to_repr` instead", skip_current_package=true)17#doc(hidden)18pub extend JoiningType with Debug::{to_repr}1920///|21pub extend JoiningType with Eq::{not_equal, equal}2223///|24pub extend JoiningType with Show::{to_string, output}2526///|27pub impl Show for JoiningType with fn output(self, logger) {28  match self {29    NonJoining => logger.write_string("NonJoining")30    JoinCausing => logger.write_string("JoinCausing")31    DualJoining => logger.write_string("DualJoining")32    LeftJoining => logger.write_string("LeftJoining")33    RightJoining => logger.write_string("RightJoining")34    Transparent => logger.write_string("Transparent")35  }36}3738///|39/// Convert a JoiningType 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_joining_type(ordinal : Int32) -> JoiningType = "%identity"4546///|47/// Get the Joining_Type for a character.48///49/// Joining_Type describes how a character takes part in cursive joining in50/// scripts such as Arabic, Syriac, and Mongolian. Transparent characters,51/// mostly nonspacing marks and format characters, do not interrupt joining52/// between the characters on either side of them. Characters that take no53/// part in cursive joining, including unassigned code points, are NonJoining.54pub fn joining_type(c : Char) -> JoiningType {55  ordinal_to_joining_type(@joining_type.lookup_joining_type(c))56}57