@std/string.ms#
Import each required symbol with import Name from "@std/string.ms".
NormalizationForm Alternative#
The four Unicode normalization forms, selected without runtime string spelling errors.
type NormalizationForm:
case Nfc
case Nfd
case Nfkc
case Nfkd
fn normalize(text: String, max_bytes: Optional[Int] = none) -> Result[String, StringError]:NormalizationForm.Nfc#
Canonical decomposition followed by canonical recomposition where Unicode permits it.
case NfcNormalizationForm.Nfd#
Canonical decomposition with combining marks placed in canonical order.
case NfdNormalizationForm.Nfkc#
Compatibility decomposition followed by canonical recomposition where Unicode permits it.
case NfkcNormalizationForm.Nfkd#
Compatibility decomposition with combining marks placed in canonical order.
case NfkdNormalizationForm.normalize#
Normalizes text with the existing String.normalize budgets and StringError cases. Omission or none adds no output budget; a supplied budget counts UTF-8 bytes.
fn normalize(text: String, max_bytes: Optional[Int] = none) -> Result[String, StringError]:StringBuilder Native type#
Mutable builder for constructing a string without repeated intermediate copies.
type StringBuilder:
fn append(value: String) -> Unit:
fn freeze() -> String:StringBuilder.append#
Appends the supplied text in order; mutation after freeze raises a sealed-builder fault.
fn append(value: String) -> Unit:StringBuilder.freeze#
Seals the builder and returns immutable text; repeated freeze returns the same text value.
fn freeze() -> String:StringError Alternative#
Errors returned by Unicode scalar conversions and bounded string operations.
type StringError:
case InvalidInput
case OutOfRange
case LimitExceeded
case Failed(message: String)impl Error for StringError:
fn message() -> String:StringError.Failed#
A string-domain failure with an explicit diagnostic supplied by an implementation.
case Failed(message: String)StringError.InvalidInput#
Scalar values, normalization form or a supplied repeat/padding/output budget is invalid.
case InvalidInputStringError.LimitExceeded#
UTF-8 output exceeds a supplied byte budget or the native string allocation limit.
case LimitExceededStringError.OutOfRange#
A strict scalar slice bound lies outside the string or its range is inverted.
case OutOfRangeStringError.Failed.message#
Original diagnostic text, returned unchanged by message().
message: StringStringError.Error.message#
Returns original Failed text, or a string-prefixed diagnostic for other cases.
fn message() -> String:from_scalars Function#
Builds text from Unicode scalar values. Invalid scalars return InvalidInput.
fn from_scalars(values: List[Int]) -> Result[String, StringError]: