unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

ucd/white_space/white_space.mbt
1///|2/// White_Space lookup data3/// Generated from PropList.txt45///|6/// White_Space trie top level: `cp >> 10` to mid block index7let white_space_trie_top : Bytes = [8  0, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,9  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,10  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,11  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,12  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,13  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,14  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,15  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,16  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,17  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,18]1920///|21/// White_Space trie mid level: leaf block indices22let white_space_trie_mid : Bytes = [23  0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 4, 2, 2,24  2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,25]2627///|28/// White_Space trie leaf level: bitsets of 128 code points, least significant bit first29let white_space_trie_leaf : Bytes = [30  0, 62, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 1, 0, 0, 0, 0, 0,31  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,32  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 7, 0, 0, 0, 131, 0, 0, 0, 0, 0, 128, 0, 0,33  0, 0,34]3536///|37/// Check whether a character has the Unicode White_Space property38pub fn is_white_space(c : Char) -> Bool {39  let cp = c.to_int()40  if cp >= 0x40000 {41    return false42  }43  let mid = (white_space_trie_top[cp >> 10].to_int() << 3) | ((cp >> 7) & 7)44  let leaf = white_space_trie_mid[mid].to_int()45  let bits = white_space_trie_leaf[(leaf << 4) | ((cp >> 3) & 15)].to_int()46  ((bits >> (cp & 7)) & 1) != 047}48