Case mapping v0.1.0

Source
Simple and full upper, lower and title case mappings, and case folding.

ToUpperSimple

pub func ToUpperSimple(scalar: char32) -> char32

The simple uppercase of scalar: one value to one, itself when it has no mapping.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to map

Returns: its single-scalar uppercase, or scalar itself when there is none

ToLowerSimple

pub func ToLowerSimple(scalar: char32) -> char32

The simple lowercase of scalar.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to map

Returns: its single-scalar lowercase, or scalar itself when there is none

ToTitleSimple

pub func ToTitleSimple(scalar: char32) -> char32

The simple titlecase of scalar: the uppercase, except for the few dozen characters whose titlecase differs.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to map

Returns: its single-scalar titlecase, or scalar itself when there is none

NextInCaseOrbit

pub func NextInCaseOrbit(scalar: char32) -> char32

The next scalar value that case-insensitive comparison treats as scalar, going round the set of values with the same simple case folding: k, K and the Kelvin sign, or σ, ς and Σ. Calling it again on each answer visits every member of the set and comes back to scalar, so a caller asking whether a set of characters holds any form of a letter tests each answer until it returns.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to start from

Returns: the next member of its set, or scalar itself when no other value folds with it

ToUpperFull

pub func ToUpperFull(
    scalar: char32,
    into: var char32[..],
    written: *var uint
) -> bool

Writes the full uppercase of scalar into into and reports how many values it took. Up to three values, so a buffer of three always suffices; reports false without writing when the room is short. Falls back to the simple mapping for the points that need no expansion, which is nearly all of them. written must be non-null and writable.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to map
intovar char32[..]receives the mapping; three values always suffice
written*var uintreceives how many values were written

Returns: false without writing when into is too short

ToLowerFull

pub func ToLowerFull(
    scalar: char32,
    into: var char32[..],
    written: *var uint
) -> bool

Writes the full lowercase of scalar into into. written must be non-null and writable.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to map
intovar char32[..]receives the mapping; three values always suffice
written*var uintreceives how many values were written

Returns: false without writing when into is too short

Fold

pub func Fold(
    scalar: char32,
    into: var char32[..],
    written: *var uint
) -> bool

Writes the full, locale-independent case folding of scalar into into. Folding is for comparison rather than display: fold both strings, and equal foldings mean the same text whatever its case. It is built from the C and F entries alone, which is what makes the answer the same in every locale. A point with no entry folds to itself. written must be non-null and writable.

Source

Parameters

NameTypeDescription
scalarchar32the scalar value to fold
intovar char32[..]receives the folding; three values always suffice
written*var uintreceives how many values were written

Returns: false without writing when into is too short