///|
test "encode" {
let bytes = @utf8.encode("hi")
inspect(bytes, content="b\"hi\"")
}///|
test "encode_with_bom" {
let bytes = @utf8.encode("hi", bom=true)
inspect(bytes, content="b\"\\xef\\xbb\\xbfhi\"")
}///|
test "decode" {
let bytes : Bytes = b"\x68\x69"
let s = @utf8.decode(bytes)
inspect(s, content="hi")
}///|
test "decode_lossy" {
let bytes : Bytes = b"\x68\x80\x69"
let s = @utf8.decode_lossy(bytes)
inspect(s, content="h\u{FFFD}i")
}fn decode_lossy(bytes : BytesView, ignore_bom? : Bool) -> Stringfn encode(str : StringView, bom? : Bool) -> BytesInstall
Installed by default