String
cameligo
val length : string -> nat
jsligo
let length: (s: string) => nat
Get the size of a string.
Michelson only supports ASCII strings so for now you can assume that each character takes one byte of storage.
let size_op = (s: string): nat => String.length(s);
cameligo
val sub : nat -> nat -> string -> string
jsligo
let sub: (offset: nat, length: nat, s: string) => string
Extract a substring from a string based on the given offset and length. For example the string "abcd" given to the function below would return "bc".
let slice_op = (s: string): string => String.sub(1n, 2n, s);
cameligo
val concat : string -> string -> string
jsligo
let concat: (a: string, b: string) => string
Concatenate two strings and return the result.
let concat_syntax = (s: string): string => String.concat(s, "test_literal");
Alternatively:
let concat_syntax_alt = (s: string): string => s + "test_literal";
cameligo
val concats : string list -> string
jsligo
let concats: (ss: list<string>) => string
Concatenate together a list of string
and return the result.