Preparation of Internationalized Strings (stringprep) in MoonBit
Preparation of Internationalized Strings ("stringprep") as defined in RFC 3454 in MoonBit
moon add chawyehsu/stringprep@stringprep.saslprep("user") // "user"
@stringprep.saslprep("I\u{00AD}X") // "IX" (soft hyphen removed)
@stringprep.saslprep("a\u{00A0}b") // "a b" (non-ASCII space mapped to ASCII space)
@stringprep.saslprep("\u{2168}") // "IX" (roman numeral normalized via NFKC)@stringprep.nameprep("CAFE") // "cafe" (case folding)
@stringprep.nameprep("\u{00DF}") // "ss" (German sharp s)
@stringprep.nameprep("安室奈美恵-with-SUPER-MONKEYS") // "安室奈美恵-with-super-monkeys"@stringprep.nodeprep("räksmörgås.josefßon.org") // "räksmörgås.josefsson.org"@stringprep.resourceprep("foo@bar") // "foo@bar"@stringprep.x520prep("UPPERCASED", case_fold=true) // "uppercased"
@stringprep.x520prep("foo@bar", case_fold=true) // "foo@bar"try @stringprep.saslprep("a\u{007F}b") catch {
StringprepError::ProhibitedCharacter(c) => println("Prohibited: \{c}")
_ => ()
}moonup pin toolchain-version# Generate NFKC normalization tables (Unicode 3.2)
python3 codegen/unicode_nfkc.py
# Generate RFC 3454 stringprep tables
python3 codegen/rfc3454_tables.pyBlog · GitHub @chawyehsu · Twitter @chawyehsu
Install
Download zipPreparation of Internationalized Strings (stringprep) in MoonBit