unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

casefold/normalized_folding.mbt
1///|2/// A key for canonical caseless matching (D145): NFD(case_fold(NFD(s))).3/// Both normalizations are needed, notably for Greek iota subscripts.4pub fn canonical_case_fold(s : StringView) -> String {5  @normalization.nfd(case_fold(@normalization.nfd(s)))6}78///|9/// Unicode NFKC_Casefold (R5). Applies the official NFKC_CF mapping, removing10/// default-ignorable code points, then normalizes the concatenation to NFC.11/// This is locale-independent and is not an identifier validity check.12pub fn nfkc_casefold(s : StringView) -> String {13  let index = Nfkc.first_change(s)14  // Unchanged input goes to NFC as it is, which copies it only once.15  if index == s.length() {16    @normalization.nfc(s)17  } else {18    @normalization.nfc(Nfkc.fold_from(s, index))19  }20}21