Methods
sprintf(formatedString, …args) → {string}
- Source:
To format the string using the specified format string and arguments.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
formatedString |
string | A format string | |
args |
* |
<repeatable> |
Arguments referenced by the format specifiers in the format string. |
Returns:
The string after formated
- Type
- string
Type Definitions
FormatKeyword
- Source:
The keyword for formating.
These are the keyword supported:
- %
- Returns the string
%
. - b
- Convert the number to binery number.
- o
- Convert the number to octal numeral.
- d
- Convert the number to decimal integer.
- x
- Convert the number to hexadecimal number (lower case).
- X
- Convert the number to hexadecimal number (upper case).
- e
- Expressing the number by scientific notation (lower case).
- E
- Expressing the number by scientific notation (upper case).
- f
- Convert the number to a float number.
- F
- Convert the number to a float number.
- g
- Convert the number. If it is a large exponents, it is same as
%e
. Otherwise%f
- G
- Convert the number. If it is a large exponents, it is same as
%E
. Otherwise%f
- T
- Return the type of the argument. If the argument is an object, it will return the name of its constructor.
- U
- Expressing the number by unicode format (upper case). E.g.
U+1AF0
. - c
- Convert the char code (number) to the char.
- p
- q
- If the argument is a number, convert it to the char with single quote.
- If the argument is a string, return it with double quote.
- s
- Return the string
- t
- Convert the argument as a boolean.
- v
- Return the value in its default format.
- If the format string is with hash (
%#v
), it will be formated as a json.
Type:
- string