All Classes Namespaces Functions Variables Groups Pages
String Functions

## Functions

int | Qore::bindex (softstring str, softstring substr, softint pos=0)
| Retrieves the byte position of a substring within a string.
int | Qore::bindex ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::brindex (softstring str, softstring substr, softint pos=-1)
| Retrieves the byte position of a substring within a string, starting the search from the end of the string.
int | Qore::brindex ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::chomp (string str)
| Removes the trailing end-of-line indicator (`"\n"` or `"\r\n"`) from a string and returns the new string (also see the chomp operator)
*string | Qore::chomp (reference str)
| Removes the trailing end-of-line indicator (`"\n"` or `"\r\n"`) from a reference to a string and returns the new string (also see the chomp operator)
nothing | Qore::chomp ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::chr (softint val, *string encoding)
| Returns a string containing a single ASCII character represented by the numeric value passed.
string | Qore::chr (any arg)
| This function variant returns a string with a single ASCII NULL ('\0'); it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
nothing | Qore::chr ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::convert_encoding (string str, string encoding)
| Performs explicit string character encoding conversions.
nothing | Qore::convert_encoding ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::f_printf (string fmt,...)
| Outputs the string passed to standard output, using the first argument as a format string; enforces field widths on arguments larger than the given field width.
string | Qore::f_printf ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::f_sprintf (string fmt,...)
| Returns a formatted string based on a format string and other arguments; enforces field widths on arguments larger than the given field width.
string | Qore::f_sprintf ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::f_vprintf (string fmt, any varg)
| Outputs the string passed to standard output, using the first argument as a format string and a second argument giving a list or a single argument to the format string; enforces field widths on arguments larger than the given field width.
string | Qore::f_vsprintf (string fmt, any varg)
| Returns a formatted string based on a format string and other arguments given as a list after the format string; enforces field widths on arguments larger than the given field width.
nothing | Qore::flush ()
| Flushes output to the console output with print(), printf(), etc.
string | Qore::force_encoding (string str, string encoding)
| Returns the first string argument tagged with the character encoding given as the second argument; does not actually change the string data.
nothing | Qore::force_encoding ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::format_number (string fmt, softfloat num)
| Returns a string of a formatted number according to a number argument and a format string.
nothing | Qore::format_number ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::get_encoding (string str)
| Returns a string describing the character encoding of the string argument passed.
nothing | Qore::get_encoding ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::index (softstring str, softstring substr, softint pos=0)
| Retrieves the character position of a substring within a string.
int | Qore::index ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::join (string str,...)
| Creates a string from separator string and a list of arguments.
string | Qore::join (string str, list l)
| Creates a string from separator string and a list of arguments.
nothing | Qore::join ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::length (softstring str)
| Returns the length in characters for the string passed.
int | Qore::length (binary bin)
| Returns the number of bytes in the binary object passed as an argument.
nothing | Qore::length ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::length (any arg)
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::ord (softstring str, softint offset=0)
| Gives the numeric value of the given byte in the string passed; if no string is passed or the offset is after the end of the string, -1 is returned.
int | Qore::ord ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
bool | Qore::parse_boolean (string str)
| tries to parse a string value as a boolean
bool | Qore::parse_boolean (...)
| returns the first value passed as a boolean
nothing | Qore::print (...)
| Outputs a string to standard output with no formatting.
string | Qore::printf (string fmt,...)
| Outputs the string passed to standard output, using the first argument as a format string; does not enforce field widths on arguments larger than the given field width.
string | Qore::printf ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
bool | Qore::regex (string str, string regex, int options=0)
| Returns True if the regular expression matches the string passed, otherwise returns False.
nothing | Qore::regex ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
*list | Qore::regex_extract (string str, string regex, int options=0)
| Returns a list of substrings in a string based on matching patterns defined by a regular expression.
nothing | Qore::regex_extract ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::regex_subst (string str, string regex, string subst, int options=0)
| Returns a string with patterns substituted according to the arguments passed.
nothing | Qore::regex_subst ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::replace (string str, string source, string target)
| Replaces all occurrences of a substring in a string with another string.
nothing | Qore::replace ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::reverse (softstring str)
| Reverses a string and returns the new string.
int | Qore::rindex (softstring str, softstring substr, softint pos=-1)
| Retrieves the character position of a substring within a string, starting the search from the end of the string.
int | Qore::rindex ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
list | Qore::split (string sep, string str, bool with_separator=False)
| Splits a string into a list of components based on a separator string.
list | Qore::split (string sep, string str, string quote, bool trim_unquoted=False)
| Splits a string into a list of components based on a separator string and a quote character.
list | Qore::split (binary sep, binary data)
| Returns a list of binary objects representing each component of the binary object separated by the bytes identified by the separator argument, with the separator removed.
list | Qore::split ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::sprintf (string fmt,...)
| Returns a formatted string based on a format string and other arguments; does not enforce field widths on arguments larger than the given field width.
string | Qore::sprintf ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::strlen (softstring str)
| Returns the length in bytes of the string argument.
nothing | Qore::strlen ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
int | Qore::strlen (any arg)
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::strmul (softstring str, softint smul, *softint offset)
| Returns a new string with a repeated string element and optionally removing trailing characters.
string | Qore::substr (softstring str, softint start)
| Returns a portion of a string starting from an integer offset.
string | Qore::substr (softstring str, softint start, softint len)
| Returns a portion of a string starting from an integer offset, with a length parameter.
nothing | Qore::substr ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::tolower (string str)
| Returns a string in all lower-case characters based on the argument passed.
nothing | Qore::tolower ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::toupper (string str)
| Returns a string in all upper-case characters based on the argument passed.
nothing | Qore::toupper ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::trim (string str, *string chars)
| Removes byte characters from the start and end of a string and returns the new string (also see the trim operator)
*string | Qore::trim (reference str, *string chars)
| Removes byte characters from the start and end of a reference to an lvalue containing a string and returns string after processing (also see the trim operator)
nothing | Qore::trim ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::trunc_str (softstring str, softint len, *string encoding)
| Returns a truncated string with no more than the given number of bytes and optionally converted to a specific character encoding.
string | Qore::vprintf (string fmt,...)
| Outputs the string passed to standard output, using the first argument as a format string and a second argument giving a list or a single argument to the format string; does not enforce field widths on arguments larger than the given field width.
string | Qore::vprintf ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
string | Qore::vsprintf (string fmt, any varg)
| Returns a formatted string based on a format string and other arguments given as a list after the format string; does not enforce field widths on arguments larger than the given field width.
string | Qore::vsprintf ()
| This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

## Detailed Description

# String Formatting

String formatting in Qore is based on c-style "printf" string formatting.

There are three types of objects in the format string:

- Plain characters, which are copied as-is to the output string
- Escape characters, which are converted and copied to the output string
- Format specifications for arguments to be included in the output string, which are preceded by the percent sign `"%"`

Note
  The percent sign `"%"` always starts a format specification unless it is followed by another `"%"` sign, in this case only one `"%"` is output (ie `"%%"` in the format string is output as a single `"%"`)

## format_specification

After the `"%"` sign, there can be zero or more formatting flags as in the following table:

Printf Formatting Flags

Flag | Description
`-` | left-justify the field
`+` | include the sign for the number (+ or -)
`0` | use zero left padding rather than space padding
space | use space padding

Then a field width specifier can optionally be given as a string of digits specifying the length of the field. With "field" functions (function names preceded by `"f_"`), these width specifiers are hard limits; that is; arguments longer than the width specified are truncated to the specified width.

For floating-point arguments, a precision specifier may be given by including a period "." and another digit string, which indicates the number of digits to appear after the decimal point.

Then the format character is given as follows:

Printf Formatting Characters

Character | Description
`s` | string
`d` | Integer, output in base 10 format
`f` | Literal floating point value
`F` | Literat floating point value
`a` | Hexadecimal floating-point output with lower-case `"0x"` and `"abcdef"`
`A` | Hexadecimal floating-point output with upper-case `"0X"` and `"ABCDEF"`
`g` | compact floating-point output using a lower-case `"e"` for exponential output when necessary
`G` | compact floating-point output using an upper-case `"E"` for exponential output when necessary
`n` | Any Qore value, formatted as a string, without any line breaks
`N` | Any Qore value, formatted as a string, with line breaks and whitespace formatting for complex objects
`x` | Integer, output in base 16 (hexadecimal) format with lower-case a-f
`X` | Integer, output in base 16 (hexadecimal) format with upper-case A-F
`y` | Any Qore value, formatted as a pseudo-YAML string, without any line breaks; this format option is similar to `"%n"`, but uses a YAML-like format. Note that the output is not guaranteed to be parsed by the yaml module's parseYAML() function; it is for display purposes only; to get real YAML functionality, use the yaml module.

String Escape Characters

Escape Characters | Description
`\n` | a newline character
`\r` | a carriage-return character
`\t` | a tab character
`\b` | a backspace character
`\f` | a form-feed character
`\num` | an 8-bit character whose value is the 1, 2, or 3 digit octal number num
`\"` | a double-quote character (`"`)

## Function Documentation

int Qore::bindex | ( | softstring | str,
|  | softstring | substr,
|  | softint | pos = `0`
| ) |  |

Retrieves the byte position of a substring within a string.

The pos argument and the return value are in byte positions; byte offsets may differ from the character offsets with multi-byte character encodings.

Code Flags:
  CONSTANT

Parameters

  str | the string to search in
  substr | the substring to find in str
  pos | the starting character position for the search

Returns
  the byte position of a substring within a string, -1 is returned if the substring is not found

Example:
  my int $i = bindex($str, $substr);
  if ($i == -1)
  printf("could not find %y in %y\n", $substr, $str);

Note
  no character encoding conversions are made by this function even if the string arguments have different character encodings

See Also
  - <string>::find(softstring, softint)
  - <string>::rfind(softstring, softint)
  - index(softstring, softstring, softint)
  - rindex(softstring, softstring, softint)
  - brindex(softstring, softstring, softint)

int Qore::bindex | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

int Qore::brindex | ( | softstring | str,
|  | softstring | substr,
|  | softint | pos = `-1`
| ) |  |

Retrieves the byte position of a substring within a string, starting the search from the end of the string.

The pos argument and the return value are in byte positions; byte offsets may differ from the character offsets with multi-byte character encodings.

Code Flags:
  CONSTANT

Parameters

  str | the string to search in
  substr | the substring to find in str
  pos | the starting character position for the search, -1 means start from the end of the string

Returns
  the byte position of a substring within a string, -1 is returned if the substring is not found

Example:
  my int $i = brindex($str, $substr);
  if ($i == -1)
  printf("could not find %y in %y\n", $substr, $str);

Note
  no character encoding conversions are made by this function even if the string arguments have different character encodings

See Also
  - <string>::find(softstring, softint)
  - <string>::rfind(softstring, softint)
  - index(softstring, softstring, softint)
  - bindex(softstring, softstring, softint)
  - rindex(softstring, softstring, softint)

int Qore::brindex | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::chomp | ( | string | str | ) |

Removes the trailing end-of-line indicator (`"\n"` or `"\r\n"`) from a string and returns the new string (also see the chomp operator)

If no EOL indicator is present in the string, this function simply returns the original string unmodified.

Code Flags:
  CONSTANT

Parameters

  str | the string to process

Returns
  the new string with any end-of-line character(s) removed

Example:
  my string $line = chomp("hello\n"); # returns "hello"

See Also
  the chomp operator

*string Qore::chomp | ( | reference | str | ) |

Removes the trailing end-of-line indicator (`"\n"` or `"\r\n"`) from a reference to a string and returns the new string (also see the chomp operator)

This variant accepts variable references, in which case it will modify the string in place and also return the modified string

Parameters

  str | a reference to an lvalue continaing the string value to process; if the lvalue does not have a string value NOTHING is returned

Returns
  the string as modified

Example:
  chomp(\$str);

nothing Qore::chomp | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::chr | ( | softint | val,
|  | *string | encoding
| ) |  |

Returns a string containing a single ASCII character represented by the numeric value passed.

Code Flags:
  CONSTANT

Parameters

  val | the byte value of the character; only the least-significant byte is used
  encoding | the character encoding tag for the string return value; if not present, the default character encoding is assumed

Returns
  a string containing a single ASCII character represented by the numeric value passed

Example:
  my string $char = chr(13);

Since
  Qore 0.8.5 the encoding argument is supported

string Qore::chr | ( | any | arg | ) |

This function variant returns a string with a single ASCII NULL ('\0'); it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

Returns
  a string with a single ASCII NULL ('\0')

nothing Qore::chr | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::convert_encoding | ( | string | str,
|  | string | encoding
| ) |  |

Performs explicit string character encoding conversions.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to convert
  encoding | the encoding for the return value

Returns
  a string corresponding to the string argument converted to the encoding given

Example:
  my string $enc = convert_encoding($str, "iso-8859-1");

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion

nothing Qore::convert_encoding | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::f_printf | ( | string | fmt,
|  |  | ...
| ) |  |

Outputs the string passed to standard output, using the first argument as a format string; enforces field widths on arguments larger than the given field width.

This function will truncate output longer than any field width given in the format string

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Parameters

  fmt | the format string
  ... | the argument(s) corresponding to format specifiers in the format string

Returns
  the formatted string output corresponding to the arguments given

Example:
  f_printf("%5s", "a long string"); # will print out "a lon"

See Also
  - String Formatting for information on the formatting string
  - printf() for a similar function that does not enforce field widths

string Qore::f_printf | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

string Qore::f_sprintf | ( | string | fmt,
|  |  | ...
| ) |  |

Returns a formatted string based on a format string and other arguments; enforces field widths on arguments larger than the given field width.

This function will truncate output longer than any field width given in the format string

Code Flags:
  CONSTANT

Parameters

  fmt | the format string
  ... | the argument(s) corresponding to format specifiers in the format string

Returns
  a formatted string corresponding to the arguments given

Example:
  my string $str = f_sprintf("%5s", "a long string"); # will return "a lon"

See Also
  - String Formatting for information on the formatting string
  - sprintf() for a similar function that does not enforce field widths

string Qore::f_sprintf | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

string Qore::f_vprintf | ( | string | fmt,
|  | any | varg
| ) |  |

Outputs the string passed to standard output, using the first argument as a format string and a second argument giving a list or a single argument to the format string; enforces field widths on arguments larger than the given field width.

This function will truncate output longer than any field width given in the format string

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Parameters

  fmt | the format string
  varg | the argument(s) corresponding to format specifiers in the format string

Returns
  the formatted string output corresponding to the arguments given

Example:
  f_vprintf("%5s %3d", ("a long string", 5000)); # will print out "a lon 500"

See Also
  - String Formatting for information on the formatting string
  - vprintf() for a similar function that does not enforce field widths

Since
  Qore 0.8.4

string Qore::f_vsprintf | ( | string | fmt,
|  | any | varg
| ) |  |

Returns a formatted string based on a format string and other arguments given as a list after the format string; enforces field widths on arguments larger than the given field width.

This function will truncate output longer than any field width given in the format string

Code Flags:
  CONSTANT

Parameters

  fmt | the format string
  varg | the argument(s) corresponding to format specifiers in the format string

Returns
  a formatted string corresponding to the arguments given

Example:
  my string $str = f_vsprintf("%5s %3d\n", ("a lon", 500)); # will return "a lon 500"

See Also
  - String Formatting for information on the formatting string
  - vsprintf() for a similar function that does not enforce field widths

Since
  Qore 0.8.4

nothing Qore::flush | ( |  | ) |

Flushes output to the console output with print(), printf(), etc.

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Example:
  flush();

string Qore::force_encoding | ( | string | str,
|  | string | encoding
| ) |  |

Returns the first string argument tagged with the character encoding given as the second argument; does not actually change the string data.

Use only in the case that a string is tagged with the wrong encoding, for example, if a string from a File object has a different encoding than the File object.

Code Flags:
  CONSTANT

Parameters

  str | the string to be returned
  encoding | the encoding to tag the return value with

Returns
  the first string argument tagged with the character encoding given as the second argument; does not actually change the string data

Example:
  my string $nstr = force_encoding($str, "iso-8859-1");

nothing Qore::force_encoding | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::format_number | ( | string | fmt,
|  | softfloat | num
| ) |  |

Returns a string of a formatted number according to a number argument and a format string.

Code Flags:
  CONSTANT

Parameters

  fmt

  the format string has the following format:
  <thousands_separator>`[`<decimal_separator><decimals>`]`
  where:
  - thousands_separator and decimal_separator are single ASCII characters defining the thousands and decimal separator characters respectively, and
  - decimals is a single digit defining how may decimals should appear after the decimal point

  num | the number to format

Returns
  a string of a formatted number according to a number argument and a format string; if the format string does not follow the given format, then an empty string is returned

Example:
  my string $nstr = format_number(".,3", -48392093894.2349); # returns "-48.392.093.894,235"

See Also
  <float>::format()

nothing Qore::format_number | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::get_encoding | ( | string | str | ) |

Returns a string describing the character encoding of the string argument passed.

Code Flags:
  CONSTANT

Parameters

  str | the string to get the encoding for

Returns
  a string describing the character encoding of the string argument passed

Example:
  my string $enc = get_encoding($str);

Note
  equivalent to <string>::encoding()

nothing Qore::get_encoding | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

int Qore::index | ( | softstring | str,
|  | softstring | substr,
|  | softint | pos = `0`
| ) |  |

Retrieves the character position of a substring within a string.

The pos argument and the return value are in character positions; byte offsets may differ from the character offsets with multi-byte character encodings.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to search in
  substr | the substring to find in str; if the character encoding of this string does not match str, then it will be converted to str's character encoding before processing
  pos | the starting character position for the search

Returns
  the character position of a substring within a string, -1 is returned if the substring is not found

Example:
  my int $i = index($str, $substr);
  if ($i == -1)
  printf("could not find %y in %y\n", $substr, $str);

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion
  INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data

Note
  equivalent to <string>::find(softstring, softint)

See Also
  - <string>::rfind(softstring, softint)
  - rindex(softstring, softstring, softint)
  - bindex(softstring, softstring, softint)
  - brindex(softstring, softstring, softint)

int Qore::index | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::join | ( | string | str,
|  |  | ...
| ) |  |

Creates a string from separator string and a list of arguments.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the separator string
  ... | the list of arguments to join; each argument will be converted to a string if necessary to be concatenated to the return value string; additionally if any string argument has a different character encoding than str, then it will be converted to str's character encoding before concatentation to the return value string

Returns
  a string created from a list and a seperator string, each element in the list will be present in the return value separated by the separator string

Example:
  my string $str = join(":", "a", "b", "c"); # returns "a:b:c"

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion

string Qore::join | ( | string | str,
|  | list | l
| ) |  |

Creates a string from separator string and a list of arguments.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the separator string
  l | the list of arguments to join; each argument will be converted to a string if necessary to be concatenated to the return value string; additionally if any string argument has a different character encoding than str, then it will be converted to str's character encoding before concatentation to the return value string

Returns
  a string created from a list and a separator string, each element in the list will be present in the return value separated by the separator string; the string returned with have the same character encoding as str

Example:
  my string $str = join(":", ("a", "b", "c")); # returns "a:b:c"

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion

Note
  equivalent to <list>::join(string)

nothing Qore::join | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

int Qore::length | ( | softstring | str | ) |

Returns the length in characters for the string passed.

Note that the byte length may differ from the character length with multi-byte character encodings. To get the byte length of a string, see strlen().

Code Flags:
  CONSTANT

Parameters

  str | the string to return the character length of

Returns
  the length in characters for the string passed

Example:
  my int $len = length($str);

Note
  - this operation has O(n) complexity if called on a string with a multi-byte character encoding, otherwise it is O(1)
  - equivalent to <string>::length()

See Also
  - strlen()
  - <string>::strlen()
  - <string>::size()

int Qore::length | ( | binary | bin | ) |

Returns the number of bytes in the binary object passed as an argument.

This variant of the function accepting a binary object as an argument works identically to the elements operator

Code Flags:
  CONSTANT

Parameters

  bin | the binary object to return the size of

Returns
  the number of bytes in the binary object

Example:
  my int $nbytes = length($bin);

nothing Qore::length | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

int Qore::length | ( | any | arg | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

int Qore::ord | ( | softstring | str,
|  | softint | offset = `0`
| ) |  |

Gives the numeric value of the given byte in the string passed; if no string is passed or the offset is after the end of the string, -1 is returned.

Code Flags:
  CONSTANT

Parameters

  str | the string containing the byte to be retrieved
  offset | the byte offset of the byte to be retrieved

Returns
  the numeric value of the given byte in the string passed; if the offset is after the end of the string or negative, -1 is returned

Example:
  my int $i = ord($str);

Note
  ord() only works on byte offsets and returns byte values

int Qore::ord | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

bool Qore::parse_boolean | ( | string | str | ) |

tries to parse a string value as a boolean

Code Flags:
  CONSTANT

Example:
  my bool $b = parse_boolean($str);

Parameters

  str | case-insensitive `"on"`, `"true"`, `"enable*"`, `"yes"` are True, the rest is interpreted as a number where 0 is False, everything else is True

Returns
  a boolean value according to the parsed argument

bool Qore::parse_boolean | ( |  | ... | ) |

returns the first value passed as a boolean

Code Flags:
  CONSTANT

Example:
  my bool $b = parse_boolean($i);

Returns
  the first value passed as a boolean

nothing Qore::print | ( |  | ... | ) |

Outputs a string to standard output with no formatting.

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Parameters

  ... | each of the arguments passed to this function will be output literally with no output formatting

Example:
  print("hello\n");

See Also
  printf() for a function that allows for formatted output

string Qore::printf | ( | string | fmt,
|  |  | ...
| ) |  |

Outputs the string passed to standard output, using the first argument as a format string; does not enforce field widths on arguments larger than the given field width.

This function will not truncate output longer than any field width given in the format string

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Parameters

  fmt | the format string
  ... | the argument(s) corresponding to format specifiers in the format string

Returns
  the formatted string output corresponding to the arguments given

Example:
  printf("%5s", "a long string"); # will print out "a long string"

See Also
  - String Formatting for information on the formatting string
  - f_printf() for a similar function that enforces field widths

string Qore::printf | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Code Flags:
  NOOP

bool Qore::regex | ( | string | str,
|  | string | regex,
|  | int | options = `0`
| ) |  |

Returns True if the regular expression matches the string passed, otherwise returns False.

Strings are converted to UTF-8 for pattern-matching; if any invalid encodings are encountered, an ENCODING-CONVERSION-ERROR is raised

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to test
  regex | the regular expression pattern
  options | regular expression options; see Regular Expression Constants for possible values

Returns
  True if the regular expression matches the string passed, otherwise returns False

Example:
  my bool $b = regex("hello", "^hel"); # returns True

Exceptions

  REGEX-COMPILATION-ERROR | There was an error compiling the regular expression
  REGEX-OPTION-ERROR | the option argument contains invalid option bits
  ENCODING-CONVERSION-ERROR | this exception could be thrown if an encoding error is encountered when converting the given strings to UTF-8

Note
  equivalent to <string>::regex(string, int)

See Also
  Regular Expressions for more information about regular expression support in Qore

nothing Qore::regex | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

*list Qore::regex_extract | ( | string | str,
|  | string | regex,
|  | int | options = `0`
| ) |  |

Returns a list of substrings in a string based on matching patterns defined by a regular expression.

Strings are converted to UTF-8 for pattern-matching; if any invalid encodings are encountered, an ENCODING-CONVERSION-ERROR is raised

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to process
  regex | the regular expression to use for matching, elements should be given in parentheses
  options | regular expression options; see Regular Expression Constants for possible values

Returns
  a list of substrings in a string based on matching patterns defined by a regular expression or NOTHING if no match was made

Example:
  my *list $rv = regex_extract("ns:element", "(\\w+):(\\w+)");

Exceptions

  REGEX-COMPILATION-ERROR | There was an error compiling the regular expression
  REGEX-OPTION-ERROR | the option argument contains invalid option bits
  ENCODING-CONVERSION-ERROR | this exception could be thrown if an encoding error is encountered when converting the given strings to UTF-8

Note
  equivalent <string>::regexExtract(string, int)

See Also
  Regular Expressions for more information about regular expression support in Qore

nothing Qore::regex_extract | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::regex_subst | ( | string | str,
|  | string | regex,
|  | string | subst,
|  | int | options = `0`
| ) |  |

Returns a string with patterns substituted according to the arguments passed.

Strings are converted to UTF-8 for pattern-matching; if any invalid encodings are encountered, an ENCODING-CONVERSION-ERROR is raised

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the source string for substitution
  regex | the regular expression pattern string
  subst | the pattern for substitution; use `$1`, `$2`, etc for patterns in parentheses in the regex argument
  options | regular expression options; see Regular Expression Constants for possible values

Returns
  a string with patterns substituted according to the arguments passed

Example:
  regex_subst("hello there", "^(.*) there$", "you $1"); @returns "you hello"

Exceptions

  REGEX-COMPILATION-ERROR | There was an error compiling the regular expression
  REGEX-OPTION-ERROR | the option argument contains invalid option bits
  ENCODING-CONVERSION-ERROR | this exception could be thrown if an encoding error is encountered when converting the given strings to UTF-8

See Also
  - replace()
  - Regular Expressions for more information about regular expression support in Qore

nothing Qore::regex_subst | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::replace | ( | string | str,
|  | string | source,
|  | string | target
| ) |  |

Replaces all occurrences of a substring in a string with another string.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to process
  source | the substring to replace; if this string has a different character encoding than str, then it will be converted to str's character encoding
  target | the replacement value for source; if this string has a different character encoding than str, then it will be converted to str's character encoding

Returns
  a string with all occurrences of source replaced with target

Example:
  my string $str = replace("hello there", "there", "you"); # returns "hello you"

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion

Note
  no regular expressions are used in this function, only direct replacements

See Also
  regex_subst()

nothing Qore::replace | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::reverse | ( | softstring | str | ) |

Reverses a string and returns the new string.

Works properly on strings with multi-byte character encodings as well (such as UTF-8)

Code Flags:
  CONSTANT

Parameters

  str | the string to reverse

Returns
  a string with all characters in reverse order

Example:
  my string $ns = reverse($str);

See Also
  reverse(list)

int Qore::rindex | ( | softstring | str,
|  | softstring | substr,
|  | softint | pos = `-1`
| ) |  |

Retrieves the character position of a substring within a string, starting the search from the end of the string.

The pos argument and the return value are in character positions; byte offsets may differ from the character offsets with multi-byte character encodings.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to search in
  substr | the substring to find in str; if the character encoding of this string does not match str, then it will be converted to str's character encoding before processing
  pos | the starting character position for the search, -1 means start from the end of the string

Returns
  the character position of a substring within a string, -1 is returned if the substring is not found

Example:
  my int $i = rindex($str, $substr);
  if ($i == -1)
  printf("could not find %y in %y\n", $substr, $str);

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion
  INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data

Note
  equivalent to <string>::rfind(softstring, softint)

See Also
  - <string>::find(softstring, softint)
  - index(softstring, softstring, softint)
  - bindex(softstring, softstring, softint)
  - brindex(softstring, softstring, softint)

int Qore::rindex | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

list Qore::split | ( | string | sep,
|  | string | str,
|  | bool | with_separator = `False`
| ) |  |

Splits a string into a list of components based on a separator string.

Code Flags:
  RET_VALUE_ONLY

Parameters

  sep | the separator string; if the separator string is not found in the string to split, then a list with only one element containing the entire string argument is returned'; if this string has a different character encoding than str, then it will be converted to str's character encoding
  str | the string to split
  with_separator | include the separator string in every element

Returns
  a list of each component of a string separated by a separator string, with the separator removed; the separator pattern will not be included in the elements of the list returned unless the with_separator argument is True

Example:
  my list $list = split(":", "some:text:here"); # returns ("some", "text", "here")

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion

Note
  equivalent to <string>::split(string, bool)

list Qore::split | ( | string | sep,
|  | string | str,
|  | string | quote,
|  | bool | trim_unquoted = `False`
| ) |  |

Splits a string into a list of components based on a separator string and a quote character.

The quote character can appear as the first part of a field, in which case it is assumed to designate the entire field. If instances of the quote character are found in the field preceded by a backquote character (`"\"`), then these quote characters are included as part of the field's text and not treated as quote characters

Code Flags:
  RET_VALUE_ONLY

Parameters

  sep | the separator string; if the separator string is not found in the string to split, then a list with only one element containing the entire string argument is returned'; if this string has a different character encoding than str, then it will be converted to str's character encoding
  str | the string to split
  quote | the quote character
  trim_unquoted | remove leading and trailing whitespace from unquoted fields

Returns
  a list of each component of a string separated by a separator string, with the separator and any enclosing quote characters removed

Example:
  my list $list = split(",", "some,'text with spaces',here", "'"); # returns ("some", "text with spaces", "here")

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion
  SPLIT-ERROR | field missing closing quote character; extra text following quoted field

Note
  equivalent to <string>::split(string, string)

Since
  Qore 0.8.6 the `trim_unquoted` parameter was added

list Qore::split | ( | binary | sep,
|  | binary | data
| ) |  |

Returns a list of binary objects representing each component of the binary object separated by the bytes identified by the separator argument, with the separator removed.

Code Flags:
  CONSTANT

Parameters

  data | the binary object to separate
  sep | the bytes that separate the fields

Returns
  a list of binary objects representing each component of the binary object separated by the bytes identified by the separator argument, with the separator removed

Example:
  my list $l = split($sep, $bin);

Note
  equivalent to <binary>::split(binary)

list Qore::split | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::sprintf | ( | string | fmt,
|  |  | ...
| ) |  |

Returns a formatted string based on a format string and other arguments; does not enforce field widths on arguments larger than the given field width.

This function will not truncate output longer than any field width given in the format string

Code Flags:
  CONSTANT

Parameters

  fmt | the format string
  ... | the argument(s) corresponding to format specifiers in the format string

Returns
  a formatted string corresponding to the arguments given

Example:
  my string $str = sprintf("%5s", "a long string"); # will return "a long string"

See Also
  - String Formatting for information on the formatting string
  - f_sprintf() for a similar function that enforces field widths

string Qore::sprintf | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

int Qore::strlen | ( | softstring | str | ) |

Returns the length in bytes of the string argument.

Note that the byte length may differ from the character length with multi-byte character encodings. For the character length of a string, see length().

Code Flags:
  CONSTANT

Parameters

  str | the string to return the byte length of

Returns
  the length in bytes for the string passed

Example:
  my int $size = strlen($str);

Note
  equivalent to <string>::strlen() and <string>::size()

See Also
  - length()
  - <string>::length()

nothing Qore::strlen | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

int Qore::strlen | ( | any | arg | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

string Qore::strmul | ( | softstring | str,
|  | softint | smul,
|  | *softint | offset
| ) |  |

Returns a new string with a repeated string element and optionally removing trailing characters.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string element to repeat in the return value string
  smul | the number of times the element should repeat
  offset | the number of characters that should be removed from the end of the string after processing

Example:
  my string $ret = strmul("%s,", 3, 1); # returns "%s,%s,%s"

Exceptions

  STRMUL-ERROR | offset is < 0 or smul < 1

string Qore::substr | ( | softstring | str,
|  | softint | start
| ) |  |

Returns a portion of a string starting from an integer offset.

Arguments can be negative, giving offsets from the end of the string. All offsets are character positions, not byte positions.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | The string to process
  start | The starting character for the substring where the first character is at offset 0; if the offset is negative, it designates the number of characters from the end of the string. If the offset is 0, then the entire string is returned.

Returns
  the substring of the string starting from an integer character offset; the rest of the string is returned after this offset

Example:
  # get the last 10 characters of a string
  my string $substr = substr($str, -10);

Exceptions

  INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data

Note
  equivalent to <string>::substr(softint)

string Qore::substr | ( | softstring | str,
|  | softint | start,
|  | softint | len
| ) |  |

Returns a portion of a string starting from an integer offset, with a length parameter.

Arguments can be negative, giving offsets from the end of the string. All offsets are character positions, not byte positions.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | The string to process
  start | The starting character for the substring where the first character is at offset 0; if the offset is negative, it designates the number of characters from the end of the string
  len | The maximum number of characters to copy; if this value is negative, the rest of the string from start will be copied to the substring, except without - len characters from the end of the string

Returns
  the substring of the string according to the arguments passed

Example:
  # get a substring 10 characters into the string except omitting the last 2 characters of the string
  my string $substr = substr($str, 10, -2);

Exceptions

  INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data

Note
  equivalent to <string>::substr(softint, softint)

nothing Qore::substr | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

string Qore::tolower | ( | string | str | ) |

Returns a string in all lower-case characters based on the argument passed.

Code Flags:
  CONSTANT

Parameters

  str | a string to process

Returns
  a string in all lower-case characters based on the argument passed

Example:
  my string $lwr = tolower($str);

Note
  - this function only processes ASCII characters
  - equivalent to <string>::lwr(string)

See Also
  - <string>::lwr()
  - <string>::upr()
  - toupper()

nothing Qore::tolower | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::toupper | ( | string | str | ) |

Returns a string in all upper-case characters based on the argument passed.

Code Flags:
  CONSTANT

Parameters

  str | a string to process

Returns
  a string in all upper-case characters based on the argument passed

Example:
  my string $upr = toupper($str);

Note
  - this function only processes ASCII characters
  - equivalent to <string>::upr(string)

See Also
  - <string>::lwr()
  - <string>::upr()
  - tolower()

nothing Qore::toupper | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::trim | ( | string | str,
|  | *string | chars
| ) |  |

Removes byte characters from the start and end of a string and returns the new string (also see the trim operator)

By default (if the second argument is omitted or passed as an empty string) the following whitespace byte characters are removed: `" "`, `"\n"`, `"\r"`, `"\t"`, `"\v"` (vertical tab, ASCII 11), and `"\0"` (null character). To trim other characters, pass a string as the second argument specifying the byte characters to be removed.

Code Flags:
  CONSTANT

Parameters

  str | the string to trim
  chars | the characters to trim from the start and end of the string (default: `" "`, `"\n"`, `"\r"`, `"\t"`, `"\v"` (vertical tab, ASCII 11), and `"\0"` (null character))

Returns
  the trimmed string

Example:
  my string $tstr = trim($str);

Bug:
  it is not possible to trim multi-byte characters from strings using this function; each byte is treated as a character. No encoding conversions are done even if the chars argument has a different character encoding than the str argument.

*string Qore::trim | ( | reference | str,
|  | *string | chars
| ) |  |

Removes byte characters from the start and end of a reference to an lvalue containing a string and returns string after processing (also see the trim operator)

By default (if the second argument is omitted or passed as an empty string) the following whitespace byte characters are removed: `" "`, `"\n"`, `"\r"`, `"\t"`, `"\v"` (vertical tab, ASCII 11), and `"\0"` (null character). To trim other characters, pass a string as the second argument specifying the byte characters to be removed.

This variant accepts variable references, in which case it will modify the string in place and also return the modified string.

Parameters

  str | a reference to an lvalue continaing the string value to process; if the lvalue does not have a string value NOTHING is returned
  chars | the characters to trim from the start and end of the string (default: `" "`, `"\n"`, `"\r"`, `"\t"`, `"\v"` (vertical tab, ASCII 11), and `"\0"` (null character))

Returns
  the trimmed string

Example:
  trim(\$str);

Bug:
  it is not possible to trim multi-byte characters from strings using this function; each byte is treated as a character. No encoding conversions are done even if the chars argument has a different character encoding than the str argument.

nothing Qore::trim | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  RUNTIME_NOOP

string Qore::trunc_str | ( | softstring | str,
|  | softint | len,
|  | *string | encoding
| ) |  |

Returns a truncated string with no more than the given number of bytes and optionally converted to a specific character encoding.

Code Flags:
  RET_VALUE_ONLY

Parameters

  str | the string to truncate
  len | the maximum byte length of the string
  encoding | if given, the string returned will be returned in the given encoding, otherwise the encoding of \ str is used for the return value

Returns
  the string truncated to be no longer than the given byte length in the character encoding given (or in the original string's character encoding if no encoding argument was passed to the function); if the string has a multi-byte character encoding, this function will guarantee that the returned string ends on a valid character (in this case the byte length of the string could be less than the limit given)

Example:
  my string $column = trunc_str($str, 80, $dsp.getOSEncoding());

Exceptions

  ENCODING-CONVERSION-ERROR | this exception could be thrown if an explicit character encoding was given and an error occurs during encoding conversion

string Qore::vprintf | ( | string | fmt,
|  |  | ...
| ) |  |

Outputs the string passed to standard output, using the first argument as a format string and a second argument giving a list or a single argument to the format string; does not enforce field widths on arguments larger than the given field width.

This function will not truncate output longer than any field width given in the format string

Restrictions:
  Qore::PO_NO_TERMINAL_IO

Parameters

  fmt | the format string
  ... | the argument(s) corresponding to format specifiers in the format string

Returns
  the formatted string output corresponding to the arguments given

Example:
  vprintf("%5s %3d", ("a long string", 5000)); # will print out "a long string 5000"

See Also
  - String Formatting for information on the formatting string
  - f_vprintf() for a similar function that enforces field widths

string Qore::vprintf | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP

string Qore::vsprintf | ( | string | fmt,
|  | any | varg
| ) |  |

Returns a formatted string based on a format string and other arguments given as a list after the format string; does not enforce field widths on arguments larger than the given field width.

This function will not truncate output longer than any field width given in the format string

Code Flags:
  CONSTANT

Parameters

  fmt | the format string
  varg | the argument(s) corresponding to format specifiers in the format string

Returns
  a formatted string corresponding to the arguments given

Example:
  my string $str = vsprintf("%5s %3d\n", ("a long string", 5000)); # will return "a long string 5000"

See Also
  - String Formatting for information on the formatting string
  - f_vsprintf() for a similar function that enforces field widths

string Qore::vsprintf | ( |  | ) |

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
  NOOP