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)
file.metadata.flac.cover.decode
Decode a flac-encoded cover metadata string.
Type:
(string) -> string
.{
color_depth : int,
description : string,
height : int,
mime : string,
number_of_colors : int?,
picture_type : int,
width : int}?
Arguments:
(unlabeled)(of typestring)
file.metadata.flac.cover.encode
Encode cover metadata for embedding with flac files.
Type:
(picture_type : int, mime : string, ?description : string, width : int,
height : int, color_depth : int, ?number_of_colors : int?, string) -> string
Arguments:
picture_type(of typeint)mime(of typestring)description(of typestring, which defaults to"")width(of typeint)height(of typeint)color_depth(of typeint)number_of_colors(of typeint?, which defaults tonull)(unlabeled)(of typestring)
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
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)
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
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","s","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.mem_usage.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, 'a) -> string
Arguments:
fields(of typebool, which defaults tofalse): Show toplevel fields around the value.(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.binary.of_int
Encode a positive (unsigned) integer using native memory representation.
Type:
(?pad : int, ?little_endian : bool, int) -> string
Arguments:
pad(of typeint, which defaults to0): Minimum length in digits (pad on the left with zeros in order to reach it)little_endian(of typebool, which defaults totrue): Whether the memory representation is little endian.(unlabeled)(of typeint): String containing the binary representation.
string.binary.to_int
Value of a positive (unsigned) integer encoded using native memory representation.
Type:
(?little_endian : bool, string) -> int
Arguments:
little_endian(of typebool, which defaults totrue): Whether the memory representation is little endian.(unlabeled)(of typestring): String containing the binary representation.
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.char.ascii.random
Return a random ASCII character
Type:
(?[int]) -> string
Arguments:
(unlabeled)(of type[int], which defaults to[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127])
string.concat
Concatenate strings.
Type:
(?separator : string, [string]) -> string
Arguments:
separator(of typestring, which defaults to"")(unlabeled)(of type[string])
string.contains
Test whether a string contains a given prefix, substring or suffix.
Type:
(?prefix : string, ?substring : string, ?suffix : string, string) -> bool
Arguments:
prefix(of typestring, which defaults to""): Prefix to look for.substring(of typestring, which defaults to""): Substring to look for.suffix(of typestring, which defaults to""): Suffix to look for.(unlabeled)(of typestring): The string to look into.
string.data_uri.decode
Decode a string using the data uri format, i.e. "data:<mime>[;base64],<data>".
Type:
(string) -> string.{mime : string}?
Arguments:
(unlabeled)(of typestring)
string.data_uri.encode
Encode a string using the data uri format, i.e. "data:<mime>[;base64],<data>".
Type:
(?base64 : bool, mime : string, string) -> string
Arguments:
base64(of typebool, which defaults totrue): Encode data using the base64 formatmime(of typestring): Data mime type(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.html
Escape HTML entities.
Type:
(?encoding : string?, string) -> string
Arguments:
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.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.extract
Extract substrings from a string. Perl compatible regular expressions are recognized. Hence, special characters should be escaped. 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. Alter natively, one can use the r/_/.exec(_) syntax for regular expressions.
Type:
(pattern : string, string) -> [int * string]
Arguments:
pattern(of typestring)(unlabeled)(of typestring)
Methods:
groups(of type[string * string]): Named captures
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.getter.concat
Combine a list of string getters [g1, ...] and return a single getter g such that: string.getter.flush(separator=s, g) = string.concat(separator=s, list.filter(fun (s) -> s != "", [string.getter.flush(g1), ...]))
Type:
([{string}]) -> {string}
Arguments:
(unlabeled)(of type[{string}])
string.getter.flush
Flush all values from a string getter and return the concatenated result. If the getter is constant, return the constant string. Otherwise, call the getter repeatedly until it returns an empty string and return the concatenated result
Type:
(?separator : string, {string}) -> string
Arguments:
separator(of typestring, which defaults to"")(unlabeled)(of type{string})
string.getter.single
Create a string getter which will return once the given string and then the empty string.
Type:
(string) -> () -> string
Arguments:
(unlabeled)(of typestring)
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:
(string) -> string
Arguments:
(unlabeled)(of typestring): Operator name.
string.id.default
Generate an identifier if no identifier was provided.
Type:
(default : string, string?) -> string
Arguments:
default(of typestring): Name from which identifier is generated if not present.(unlabeled)(of typestring?): Proposed identifier.
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.is_int
Test whether a string is a valid integer.
Type:
(string) -> bool
Arguments:
(unlabeled)(of typestring)
string.length
Get the length of a string.
Type:
(string) -> int
Arguments:
(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.match
Match a string with an expression. Perl compatible regular expressions are recognized. Hence, special characters should be escaped. Alternatively, one can use the the r/_/.test(_) syntax for regular expressions.
Type:
(pattern : string, string) -> bool
Arguments:
pattern(of typestring)(unlabeled)(of typestring)
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.null_terminated
Add a null character at the end of a string.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring): String.
string.quote
Return a quoted copy of the given string. By default, the string is assumed to be "utf8" encoded and is escaped following JSON and javascript specification.
Type:
(?encoding : string?, string) -> string
Arguments:
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.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.replace
Replace all substrings matched by a pattern by another string returned by a function. Alternatively, one can use the r/_/g.replace(_) syntax for regular expressions.
Type:
(pattern : string, ((string) -> string), string) -> string
Arguments:
pattern(of typestring): Pattern (regular expression) of substrings which should be replaced.(unlabeled)(of type(string) -> string): Function getting a matched substring an returning the string to replace it with.(unlabeled)(of typestring): String whose substrings should be replaced.
string.residual
What remains of a string after a given prefix.
Type:
(prefix : string, string) -> string?
Arguments:
prefix(of typestring): Requested prefix.(unlabeled)(of typestring)
string.split
Split a string at "separator". Perl compatible regular expressions are recognized. Hence, special characters should be escaped. Alternatively, one can use the r/_/.split(_) syntax for regular expressions.
Type:
(separator : string, string) -> [string]
Arguments:
separator(of typestring)(unlabeled)(of typestring)
string.split.first
Split a string in two at first "separator".
Type:
(separator : string, string) -> string * string
Arguments:
separator(of typestring)(unlabeled)(of typestring)
string.sub
Get a substring of a string. Returns "" if no such substring exists.
Type:
(string, start : int, length : int) -> string
Arguments:
(unlabeled)(of typestring)start(of typeint): Return a sub string starting at this position. First position is 0.length(of typeint): Return a sub string oflengthcharacters.
string.to_float
Convert a string to a float.
Type:
(?default : float, string) -> float
Arguments:
default(of typefloat, which defaults to0.)(unlabeled)(of typestring)
string.to_int
Convert a string to a int.
Type:
(?default : int, string) -> int
Arguments:
default(of typeint, which defaults to0)(unlabeled)(of typestring)
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)
string.unquote
Return an unquoted copy of the given string. Quotes are removed by trying to parse the string following the JSON string escaping convention.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring)
string_of_metadata
Standard function for displaying metadata. Shows artist and title, using "Unknown" when a field is empty.
Type:
([string * string]) -> string
Arguments:
(unlabeled)(of type[string * string]): Metadata packet to be displayed.
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)
url.split
Split an url of the form foo?arg=bar&arg2=bar2 into ("foo",[("arg","bar"),("arg2","bar2")]). The returned strings are decoded (see url.decode).
Type:
(string) -> string * [string * string]
Arguments:
(unlabeled)(of typestring): Url to split.
url.split_args
Split the arguments of an url of the form arg=bar&arg2=bar2 into [("arg","bar"),("arg2","bar2")]. The returned strings are decoded (see url.decode).
Type:
(string) -> [string * string]
Arguments:
(unlabeled)(of typestring): Argument string to split.
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)