unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

ucd/line_break.mbt
1///|2/// Line_Break values and lookup3/// Generated from LineBreak.txt45///|6/// Unicode Line_Break values7/// See UAX #14: https://www.unicode.org/reports/tr14/#Table18#derive(Debug, Eq)9pub(all) enum LineBreak {10  AI // Ambiguous (Alphabetic or Ideographic)11  AK // Aksara12  AL // Alphabetic13  AP // Aksara Pre-Base14  AS // Aksara Start15  B2 // Break Opportunity Before and After16  BA // Break After17  BB // Break Before18  BK // Mandatory Break19  CB // Contingent Break Opportunity20  CJ // Conditional Japanese Starter21  CL // Close Punctuation22  CM // Combining Mark23  CP // Close Parenthesis24  CR // Carriage Return25  EB // Emoji Base26  EM // Emoji Modifier27  EX // Exclamation/Interrogation28  GL // Non-breaking ("Glue")29  H2 // Hangul LV Syllable30  H3 // Hangul LVT Syllable31  HH // Unambiguous Hyphen32  HL // Hebrew Letter33  HY // Hyphen34  ID // Ideographic35  IN // Inseparable36  IS // Infix Numeric Separator37  JL // Hangul L Jamo38  JT // Hangul T Jamo39  JV // Hangul V Jamo40  LF // Line Feed41  NL // Next Line42  NS // Nonstarter43  NU // Numeric44  OP // Open Punctuation45  PO // Postfix Numeric46  PR // Prefix Numeric47  QU // Quotation48  RI // Regional Indicator49  SA // Complex Context Dependent (South East Asian)50  SG // Surrogate51  SP // Space52  SY // Symbols Allowing Break After53  VF // Virama Final54  VI // Virama55  WJ // Word Joiner56  XX // Unknown57  ZW // Zero Width Space58  ZWJ // Zero Width Joiner59}6061///|62#deprecated("Use `Debug::to_repr` instead", skip_current_package=true)63#doc(hidden)64pub extend LineBreak with Debug::{to_repr}6566///|67pub extend LineBreak with Eq::{not_equal, equal}6869///|70pub extend LineBreak with Show::{to_string, output}7172///|73pub impl Show for LineBreak with fn output(self, logger) {74  logger.write_string(75    match self {76      AI => "AI"77      AK => "AK"78      AL => "AL"79      AP => "AP"80      AS => "AS"81      B2 => "B2"82      BA => "BA"83      BB => "BB"84      BK => "BK"85      CB => "CB"86      CJ => "CJ"87      CL => "CL"88      CM => "CM"89      CP => "CP"90      CR => "CR"91      EB => "EB"92      EM => "EM"93      EX => "EX"94      GL => "GL"95      H2 => "H2"96      H3 => "H3"97      HH => "HH"98      HL => "HL"99      HY => "HY"100      ID => "ID"101      IN => "IN"102      IS => "IS"103      JL => "JL"104      JT => "JT"105      JV => "JV"106      LF => "LF"107      NL => "NL"108      NS => "NS"109      NU => "NU"110      OP => "OP"111      PO => "PO"112      PR => "PR"113      QU => "QU"114      RI => "RI"115      SA => "SA"116      SG => "SG"117      SP => "SP"118      SY => "SY"119      VF => "VF"120      VI => "VI"121      WJ => "WJ"122      XX => "XX"123      ZW => "ZW"124      ZWJ => "ZWJ"125    },126  )127}128129///|130/// Convert a LineBreak ordinal, below 49, to the enum value.131///132/// A constructor without arguments is its ordinal on every backend. A133/// `match` or a table would cost a jump table or a load on wasm, wasm-gc134/// and JS, slower there than the trie lookup itself.135fn ordinal_to_line_break(ordinal : Int32) -> LineBreak = "%identity"136137///|138/// Get the Line_Break for a character.139///140/// Line_Break is the property the line breaking rules of UAX #14 are141/// written in terms of. It is a property of a single character, and the142/// value is the one the Unicode Character Database assigns: rule LB1 of143/// the algorithm, which resolves AI, CJ, SA, SG, and XX to other classes,144/// is not applied. Unassigned code points are XX, except in ranges145/// reserved for characters of a known class, such as ID in the CJK146/// ideograph blocks and in planes 2 and 3.147pub fn line_break(c : Char) -> LineBreak {148  ordinal_to_line_break(@line_break.lookup_line_break(c))149}150