Skip to main content

Text, Blob, and Char

Text and binary data helpers with conversions and search utilities. Most of these functions are trusted runtime wrappers: they are useful in programs, but proofs should rely on the contracts and Spec models rather than assuming the verifier can reason about Unicode internals.

Text (mo:core/Text)

Unicode text operations and pattern-based search. See Text for the full API and spec helpers.

Example: Normalizing Text

text.sr9
import Text "mo:core/Text";
import Char "mo:core/Char";

module {
public func normalize(t : Text.Text) : Text.Text
requires true;
ensures true;
{
let ws : Text.Pattern = #predicate(Char.isWhitespace);
Text.toLower(Text.trim(t, ws))
};
}

Char (mo:core/Char)

Character helpers and classification. See Char for the full API.

Blob (mo:core/Blob)

Binary data utilities. See Blob for the full API and spec helpers.

Principal (mo:core/Principal)

Principal conversions. Use these for identity serialization and access-control contracts alongside shared caller checks. See Principal for the full API.

Summary

  • Text provides construction, transformation, and search utilities.
  • Char and Blob support conversion and comparison helpers.
  • Principal bridges between blob representation and actor principals.