String
%
pattern % [...,(k,v),...] changes in the pattern occurrences of:
$(k)intov- `$(if $(k2),"a","b") into "a" if k2 is found in the list, "b" otherwise.
Type:
(string, [string * string]) -> string
Arguments:
(unlabeled)(of typestring)(unlabeled)(of type[string * string])
^
Concatenate strings.
Type:
(string, string) -> string
Arguments:
(unlabeled)(of typestring)(unlabeled)(of typestring)
bool_of_string
Convert a string to a bool. Raises error.failure("a string to a bool") if conversion fails and default is null
Type:
(string, ?default : bool?) -> bool
Arguments:
(unlabeled)(of typestring)default(of typebool?, which defaults tonull)
float_of_string
Convert a string to a float. Raises error.failure("a string to a float") if conversion fails and default is null
Type:
(string, ?default : float?) -> float
Arguments:
(unlabeled)(of typestring)default(of typefloat?, which defaults tonull)
int_of_string
Convert a string to a int. Raises error.failure("a string to a int") if conversion fails and default is null
Type:
(string, ?default : int?) -> int
Arguments:
(unlabeled)(of typestring)default(of typeint?, which defaults tonull)
irc.channel
Contents of an IRC channel.
Type:
(?server : string, ?port : int, ?channel : string, ?nick : string,
?limit : int) -> () -> string
Example:
# Display messages in the #liquidsoap-test room over a video
s = single("test.mp4")
s = video.add_text.native(irc.channel(channel="#liquidsoap-test"), s)
Arguments:
server(of typestring, which defaults to"irc.libera.chat"): IRC server.port(of typeint, which defaults to6667): Port for IRC server.channel(of typestring, which defaults to"#liquidsoap"): IRC chan to join.nick(of typestring, which defaults to"liquidbot"): Nickname.limit(of typeint, which defaults to10): Limit to n last messages
json.object
Create a generic json object
Type:
() -> json
Methods:
add(of type(string, 'a) -> unit): Add or replace a newkey/valuepair to the object.remove(of type(string) -> unit): Remove a key from the object. Does not nothing if the key does not exist.stringify(of type(?compact : bool, ?json5 : bool) -> string): Render object as json string.
json.stringify
Convert a value to JSON. If the value cannot be represented as JSON (for instance a function), a error.json exception is raised.
Type:
(?compact : bool, ?json5 : bool, 'a) -> string
Arguments:
compact(of typebool, which defaults tofalse): Output compact text.json5(of typebool, which defaults tofalse): Use json5 extended spec.(unlabeled)(of type'a)
json.value
Create a generic json value
Type:
('a) -> json
Arguments:
(unlabeled)(of type'a)
metadata.id3v2.render
Return a string representation of a id3v2 metadata tag
Type:
([string * string], ?version : int) -> string
Arguments:
(unlabeled)(of type[string * string])version(of typeint, which defaults to3): Tag version. One of: 3 or 4
metadata.parse.amplify
Parse an amplify metadata. Parsing is the same as in the amplify operator. Metadata can be of the form: "
Type:
(string) -> float
Arguments:
(unlabeled)(of typestring)
regexp
Create a regular expression
Type:
(?flags : [string], string) -> regexp
Arguments:
flags(of type[string], which defaults to[]): List of flags. Valid flags:"i","g","m".(unlabeled)(of typestring)
Methods:
exec(of type(string) -> [int * string].{groups : [string * string]}): Extract substrings from a string. Returns a list of (index,value). If the list does not have a pair associated to some index, it means that the corresponding pattern was not found.replace(of type(((string) -> string), string) -> string): Replace substrings matched by the regexp by another string returned by a function.split(of type(string) -> [string]): Split a string on the given regular expression.test(of type(string) -> bool): Match a string with the expressionn.
runtime.memory.prettify_bytes
Returns a human-redable description of an amount of bytes.
Type:
(?float_printer : ((float) -> string)?, ?signed : bool?, ?bits : bool?,
?binary : bool?, int) -> string
Arguments:
float_printer(of type((float) -> string)?, which defaults tonull)signed(of typebool?, which defaults tonull)bits(of typebool?, which defaults tonull)binary(of typebool?, which defaults tonull)(unlabeled)(of typeint)
string
Return the representation of a value.
Type:
(?fields : bool, ?print_binary : bool, 'a) -> string
Arguments:
fields(of typebool, which defaults tofalse): Show toplevel fields around the value.print_binary(of typebool, which defaults totrue): Whenfalse, strings marked as binary are masked and returned as<string>(unlabeled)(of type'a)
string.annotate.parse
Parse a string of the form <key>=<value>,...:<uri> as given by the annotate: protocol
Type:
(string) -> [string * string] * string
Arguments:
(unlabeled)(of typestring)
string.base64.decode
Decode a Base64 encoded string.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring)
string.base64.encode
Encode a string in Base64.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring)
string.capitalize
Return a string with the first character set to upper case (capitalize), or to lower case (uncapitalize).
Type:
(?capitalize : bool, ?space_sensitive : bool, string) -> string
Arguments:
capitalize(of typebool, which defaults totrue): Capitalize if true, uncapitalize otherwisespace_sensitive(of typebool, which defaults totrue): Capitalize each space separated sub-string.(unlabeled)(of typestring)
string.case
Convert a string to lower or upper case.
Type:
(?lower : bool, string) -> string
Arguments:
lower(of typebool, which defaults totrue): Convert to lower case if true and uppercase otherwise.(unlabeled)(of typestring)
string.char
Create a string with one character.
Type:
(int) -> string
Arguments:
(unlabeled)(of typeint): Code of the character.
string.chars
Split string into characters. Raises error.invalid on errors.
Type:
(?encoding : string?, string) -> [string]
Arguments:
encoding(of typestring?, which defaults tonull): Encoding used to split characters. Should be one of:"utf8"or"ascii"(unlabeled)(of typestring)
string.compare
Compare strings in lexicographical order.
Type:
(string, string) -> int
Arguments:
(unlabeled)(of typestring)(unlabeled)(of typestring)
string.concat
Concatenate strings.
Type:
(?separator : string, [string]) -> string
Arguments:
separator(of typestring, which defaults to"")(unlabeled)(of type[string])
string.digest
Return an MD5 digest for the given string.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring)
string.escape
Escape special characters in an string. By default, the string is assumed to be "utf8" encoded and is escaped following JSON and javascript specification.
Type:
(?special_char : ((encoding : string, string) -> bool)?,
?escape_char : ((encoding : string, string) -> string)?,
?encoding : string?, string) -> string
Arguments:
special_char(of type((encoding : string, string) -> bool)?, which defaults tonull): Returntrueif the given character (passed as a string) should be escaped. Defaults to control characters for"utf8"and control characters and any character above\x7E(non-printable characters) for"ascii".escape_char(of type((encoding : string, string) -> string)?, which defaults tonull): Function used to escape a character. Defaults to\xxxoctal notation for"ascii"and\uxxxxhexadecimal notation for"utf8".encoding(of typestring?, which defaults tonull): One of:"ascii"or"utf8". Ifnull,utf8is tried first andasciiis used as a fallback if this fails.(unlabeled)(of typestring)
string.escape.all
Escape each character in the given string using a specific escape sequence.
Type:
(?format : string, string) -> string
Arguments:
format(of typestring, which defaults to"utf8"): Escape format. One of:"octal","hex"or"utf8".(unlabeled)(of typestring)
string.escape.special_char
Default function to detect characters to escape. See string.escape for more details.
Type:
(?encoding : string, string) -> bool
Arguments:
encoding(of typestring, which defaults to"utf8"): One of:"ascii"or"utf8".(unlabeled)(of typestring)
string.float
String representation of a float.
Type:
(?decimal_places : int?, float) -> string
Arguments:
decimal_places(of typeint?, which defaults tonull): Number of decimal places.(unlabeled)(of typefloat)
string.hex_of_int
Hexadecimal representation of an integer.
Type:
(?pad : int, int) -> string
Arguments:
pad(of typeint, which defaults to0): Minimum length in digits (pad on the left with zeros in order to reach it).(unlabeled)(of typeint)
string.id
Generate an identifier with given operator name.
Type:
(?category : string, string) -> string
Arguments:
category(of typestring, which defaults to""): Category(unlabeled)(of typestring): Operator name.
string.index
Index where a substring occurs in a string. The function returns -1 if the substring is not present
Type:
(substring : string, string) -> int
Arguments:
substring(of typestring): Substring to look for.(unlabeled)(of typestring): String in which to look.
string.length
Return the string's length using the given encoding. Raises error.invalid on errors.
Type:
(?encoding : string?, string) -> int
Arguments:
encoding(of typestring?, which defaults tonull): Encoding used to split characters. Should be one of:"utf8"or"ascii"(unlabeled)(of typestring)
string.make
Create a string of a given length using the given character.
Type:
(?char_code : int, int) -> string
Arguments:
char_code(of typeint, which defaults to32): Character code.(unlabeled)(of typeint): String length.
string.nth
Retrieve a character in a string. Raises error.not_found if character does not exist.
Type:
(string, int) -> int
Example:
c = string.nth("abcde", 2)
print(c) # should print 99 which is the ascii code for "c"
Arguments:
(unlabeled)(of typestring): String to look into.(unlabeled)(of typeint): Index of the character.
string.recode
Convert a string. Effective only if Camomile is enabled.
Type:
(?in_enc : string?, ?out_enc : string, string) -> string
Arguments:
in_enc(of typestring?, which defaults tonull): Input encoding. Autodetected if null.out_enc(of typestring, which defaults to"UTF-8"): Output encoding.(unlabeled)(of typestring)
string.sub
Get a substring of a string. Returns "" if no such substring exists.
Type:
(string, start : int, ?encoding : string?, length : int) -> string
Arguments:
(unlabeled)(of typestring)start(of typeint): Return a sub string starting at this position. First position is 0.encoding(of typestring?, which defaults tonull): Encoding used to split characters. Should be one of:"utf8"or"ascii"length(of typeint): Return a sub string oflengthcharacters.
string.trim
Return a string without leading and trailing whitespace.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring)
string.unescape
This function is the inverse of string.escape.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring)
url.decode
Decode an encoded url (e.g. "%20" becomes " ").
Type:
(?plus : bool, string) -> string
Arguments:
plus(of typebool, which defaults totrue)(unlabeled)(of typestring)
url.encode
Encode an url (e.g. " " becomes "%20").
Type:
(?plus : bool, string) -> string
Arguments:
plus(of typebool, which defaults totrue)(unlabeled)(of typestring)
xml.stringify
Convert a value to XML. If the value cannot be represented as XML (for instance a function), a error.xml exception is raised.
Type:
(?compact : bool, 'a) -> string
Arguments:
compact(of typebool, which defaults tofalse): Output compact text.(unlabeled)(of type'a)
yaml.stringify
Convert a value to YAML. If the value cannot be represented as YAML (for instance a function), a error.yaml exception is raised.
Type:
(?scalar_style : string, ?layout_style : string, 'a) -> string
Arguments:
scalar_style(of typestring, which defaults to"any"): Scalar style. One of: "any", "plain", "single_quoted", "double_quoted", "literal" or "folded".layout_style(of typestring, which defaults to"any"): Layout style. One of: "any", "block" or "flow".(unlabeled)(of type'a)