Improve string/interpolation formatting (#1491)

- The '#' component for type 's' now escapes the string characters
- The '#' component for type 'f' now prints a precision suffix
- The new 'q' component specifies a precision value
This commit is contained in:
Sylvie
2024-09-01 12:54:26 -04:00
committed by GitHub
parent 2fb76ce584
commit 6b8d33529e
13 changed files with 128 additions and 48 deletions

View File

@@ -2,15 +2,16 @@ println STRFMT("%+d %++d", 42, 42)
println STRFMT("%#x %##x", 42, 42)
println STRFMT("%-4d %--4d", 42, 42)
println STRFMT("%.f %..f", 42.0, 42.0)
println STRFMT("%qf %q.16f", 42.0, 42.0)
DEF N = 42
println "{5d:N} {5d5:N}"
println "{x:N} {xx:N}"
println STRFMT("%+s", "hello")
println STRFMT("%#s", "hello")
println STRFMT("%0s", "hello")
println STRFMT("%.5s", "hello")
println STRFMT("%q16s", "hello")
println STRFMT("%#d", 42)
println STRFMT("%.5d", 42)