Standard Library: String functions
char
[%char: code]
→ string?
Prints the Unicode character represented by the Unicode code point code
.
If code
doesn't correspond to a valid character, prints nothing.
Parameters
code
← int
The Unicode code point representing the character to print.
lines
[%lines: str]
→ list
Splits string str
by line feed characters (0x0A, \n
) and returns a list of the results.
Parameters
str
← string
The input string.
lower
[%lower: str]
→ string
Converts string str
to lowercase and returns the result.
Parameters
str
← string
The input string.
ord
[%ord: ch]
→ int?
Prints the Unicode code point of the specified character as an int
value.
If an empty string is passed, prints nothing.
Parameters
ch
← string
The input string that provides the character. This can be any length; the function only uses the first code point in the string.
Example
[ord: \s]
# -> 32
ord-all
[%ord-all: str]
→ list
Prints a list of int
values containing the Unicode code points contained in str
.
Parameters
str
← string
The input string.
Example
# Prints a list of hex values of each code point from the input string
[%as-unicode-hex: str] {
[cat: **[ord-all: <str>]
|> cat: [num-fmt: (:: system = hex; upper = @true)] U\+[]
|> tuple
]
}
[as-unicode-hex: 👨👩👦👦]
# -> (U+1F468; U+200D; U+1F469; U+200D; U+1F466; U+200D; U+1F466)
split
[%split: str; sep?]
→ list
Splits the input text by sep
into a list of strings. If sep
is omitted, splits into characters.
Parameters
str
← string
The input string.
sep
← string
(optional)
The delimiter to split on. If omitted, the string will be split into individual characters.
seg
[%seg: str; size]
→ list
Segments the input text into a list of strings of size
length.
Parameters
str
← string
The input string.
size
← int
The size of the segments to produce.
upper
[%upper: str]
→ string
Converts string str
to uppercase and returns the result.