diff --git a/doc/extensions/strings.md b/doc/extensions/strings.md new file mode 100644 index 00000000..3fafe8dc --- /dev/null +++ b/doc/extensions/strings.md @@ -0,0 +1,60 @@ + + +# Strings + +## string.format(list) -> string + +### Format + +`%[.precision]conversion` + +### Precision + +Optional. In the form of a period `.` followed by a required positive decimal digit sequence. The default precision is `6`. Not all conversions support precision. + +### Conversion + +| Character | Precision | Description | +| --- | --- | --- | +| `s` | N |
bool | The value is foramtted as true or false . |
int | The value is formatted in base 10 with a preceding - if the value is negative. No insignificant 0 s must be included. |
uint | The value is formatted in base 10. No insignificant 0 s must be included. |
double | The value is formatted in base 10. No insignificant 0 s must be included. If there are no significant digits after the . then it must be excluded. |
bytes | The value is formatted as if `string(value)` was performed and any invalid UTF-8 sequences are replaced with \ufffd . Multiple adjacent invalid UTF-8 sequences must be replaced with a single \ufffd . |
string | The value is included as is. |
duration | The value is formatted as decimal seconds as if the value was converted to double and then formatted as %ds . |
timestamp | The value is formatted according to RFC 3339 and is always in UTC. |
null_type | The value is formatted as null . |
type | The value is formatted as a string. |
list | The value is formatted as if each element was formatted as "%s".format([element]) , joined together with , and enclosed with [ and ] . |
map | The value is formatted as if each entry was formatted as "%s: %s".format([key, value]) , sorted by the formatted keys in ascending order, joined together with , , and enclosed with { and } . |
int | The value is formatted in base 10 with a preceding - if the value is negative. No insignificant 0 s must be included. |
uint | The value is formatted in base 10. No insignificant 0 s must be included. |
double | The value is formatted in base 10. No insignificant 0 s must be included. If there are no significant digits after the . then it must be excluded. |
int uint | The value is formatted in base 16 with no insignificant digits. If the value was negative - is prepended. |
string | The value is formatted as if `bytes(value)` was used to convert the string to bytes and then each byte is formatted in base 16 with exactly 2 digits. |
bytes | The value is formatted as if each byte is formatted in base 16 with exactly 2 digits. |