aiken/primitive/string

Functions

Constructing

from_bytearray(bytes: ByteArray) -> String

Convert a ByteArray into a String

This functions fails if the underlying ByteArray isn’t UTF-8-encoded. In particular, you cannot convert arbitrary hash digests using this function.

For converting arbitrary ByteArrays, use bytearray.to_hex.

string.from_bytearray("foo") == @"foo"
string.from_bytearray(#"666f6f") == @"foo"
string.from_bytearray(some_hash) -> fail

from_int(n: Int) -> String

Convert an Int to its String representation.

string.from_int(42) == @"42"

Combining

concat(left: String, right: String) -> String

Combine two String together.

string.concat(left: @"Hello", right: @", World!") == @"Hello, World!"

join(list: List<String>, delimiter: String) -> String

Join a list of strings, separated by a given delimiter.

string.join([], @"+") == @""
string.join([@"a", @"b", @"c"], @",") == @"a,b,c"

Transforming

to_bytearray(self: String) -> ByteArray

Convert a String into a ByteArray

string.to_bytearray(@"foo") == "foo"
Search Document