Good evening,
I’m stuck on the following syntax problem but I can’t find the trick. I tried to get an array of bytes as Nat8 from a Text.
The documentation:
let encodeUtf8 : Text -> Blob
Returns the UTF-8 encoding of the given text
My test snippet:
public func testUtf8() : async Bool {
let b : Blob = Text.encodeUtf8("FooBär☃");
//let a : [Nat8] = Blob.toArray(Text.encodeUtf8("FooBär☃"));
return true;
};
The error:
type error [M0072], field encodeUtf8 does not exist in type
module {type Pattern = {#char : Char; #predicate : Char → Bool; #text : Text}; compare : (Text, Text) → {#equal; #greater; #less}; compareWith : (Text, Text, (Char, Char) → {#equal; #greater; #less}) → {#equal; #greater; #less}; concat : (Text, Text) → Text; contains : (Text, Pattern) → Bool; endsWith : (Text, Pattern) → Bool; equal : (Text, Text) → Bool; fromChar : Char → Text; fromIter : Iter/1 → Text; greater : (Text, Text) → Bool; greaterOrEqual : (Text, Text) → Bool; hash : Text → Hash; join : (Text, Iter/1) → Text; less : (Text, Text) → Bool; lessOrEqual : (Text, Text) → Bool; map : (Text, Char → Char) → Text; notEqual : (Text, Text) → Bool; replace : (Text, Pattern, Text) → Text; size : Text → Nat; split : (Text, Pattern) → Iter/1; startsWith : (Text, Pattern) → Bool; stripEnd : (Text, Pattern) → ?Text; stripStart : (Text, Pattern) → ?Text; toIter : Text → Iter/1; tokens : (Text, Pattern) → Iter/1; translate : (Text, Char → Text) → Text; trim : (Text, Pattern) → Text; trimEnd : (Text, Pattern) → Text; trimStart : (Text, Pattern) → Text}