def code_width_by

cli@0.2.0.0 · cli.bend:851

import cli@0.2.0.0/cli.bend as Cli
import Base

851# A code point's own width: controls, marks, 200B-200F and tag characters
852# (E0000-E007F) are 0, East Asian Wide and Fullwidth are 2, the rest 1.
853def code_width_by(small: Bool, +code: U32) -> Nat:
854  match small:
855    case True{}:
856      Bool.pick(Nat, Bool.or(U32.is_le(code, 31),
857        Bool.and(U32.is_ge(code, 127), U32.is_le(code, 159))), 0n, 1n)
858    case False{}:
859      Bool.pick(Nat, Bool.or(unicode_is_zero_mark(code),
860        Bool.or(Bool.and(U32.is_ge(code, 8203), U32.is_le(code, 8207)),
861          Bool.and(U32.is_ge(code, 917504), U32.is_le(code, 917631)))), 0n,
862        Bool.pick(Nat, unicode_is_wide(code), 2n, 1n))

Uses (10)

Used by (1)