///|
/// Text secrets travel as UTF-8 bytes: encode the string, split the bytes.
/// A refusal names the first reason the text cannot be encoded, though
/// every Unicode scalar value encodes - the check is the ceiling.
fn utf8_bytes(text : String) -> Array[Int32] {
let encoded = @utf8.encode(text[:])
let out : Array[Int32] = []
for i in 0.. String? {
let buf : Buffer = Buffer::Buffer()
for i in 0.. None
}
}
///|
test "utf8 text round trips through bytes" {
let plain = "钥匙 backup 生 keys 🔑 12345"
let bytes = utf8_bytes(plain)
assert_eq(bytes.length() > 16, true)
assert_eq(utf8_text(bytes), Some(plain))
// Bytes that are not UTF-8 decline politely.
assert_eq(utf8_text([0xFF, 0xFE]), None)
}