2.5.23. String¶
TODO.
2.5.23.1. Instruction¶
-
target =
string.cmp
op1 op2
[string::Cmp]
¶ Target: bool Operator 1: string Operator 2: string Compares op1 with op2 and returns True if their characters match. Returns False otherwise.
-
target =
string.concat
op1 op2
[string::Concat]
¶ Target: string Operator 1: string Operator 2: string Concatenates op1 with op2 and returns the result.
-
target =
string.decode
op1 op2
[string::Decode]
¶ Target: string Operator 1: ref<bytes> Operator 2: enum { } Converts bytes op1 into a string, assuming characters are encoded in character set op2. Supported character sets are currently:
ASCII
,UTF8
,UTF16LE
,UTF16BE
,UTF32LE
,UTF32BE
. tIf the string cannot be decoded with the given character set, the instruction tthrows an ~~DecodingError exception. If the character set given is not supported, tthe instruction throws a ~~ValueError exception. .. todo:: Support further character sets.
-
target =
string.encode
op1 op2
[string::Encode]
¶ Target: ref<bytes> Operator 1: string Operator 2: enum { } Converts op1 into bytes, encoding characters using the character set op2. Supported character sets are currently:
ASCII
,UTF8
. If the any characters cannot be encoded with the given character set, they will be replaced with place-holders. If the character set given is not supported, the instruction throws a ~~ValueError exception. Todo: We need to figure out how to support more character sets.
-
target =
string.find
op1 op2
[string::Find]
¶ Target: int<64> Operator 1: string Operator 2: string Searches op2 in op1, returning the start index if it find it. Returns -1 if it does not find op2 in op1.
-
target =
string.join
op1 op2
[string::Join]
¶ Target: string Operator 1: string Operator 2: ref<list<*>> Renders each of the elements in list op2 into a string (as if one printed it), and then concatenates them using op1 as the separator.
-
target =
string.length
op1
[string::Length]
¶ Target: int<64> Operator 1: string Returns the number of characters in the string op1.
-
target =
string.lt
op1 op2
[string::Lt]
¶ Target: bool Operator 1: string Operator 2: string Compares op1 with op2 and returns True if op1 is lexicographically smaller than op2. Returns False otherwise.
-
target =
string.substr
op1 op2 op3
[string::Substr]
¶ Target: string Operator 1: string Operator 2: int<64> Operator 3: int<64> Extracts the substring of length op3 from op1 that starts at position op2.