method
Unicode.is_valid_utf8
Unicode.is_valid_utf8(s) -> bool
Strictly validates that the bytes are well-formed UTF-8: correct continuation bytes, no overlong encodings, no surrogate code points, and nothing above U+10FFFF. Use it as a gate on untrusted input — a chat line, a downloaded file, a mod's data — before treating it as text.
Parameters
sthe bytes to validateExample
program Valid {
entry {
if Unicode.is_valid_utf8("safe text") { print(1) } else { print(0) }
}
}