std.fmt
formatInt function
pub fn formatInt(value: int, spec: string): string
An int through a .NET numeric specifier (N0, D5, X, ...). An invalid specifier is a
panic rather than an error value: it is a literal in the source and does not depend on the
input.
stdlib/std/fmt.lyr:21
formatUint function
pub fn formatUint(value: uint, spec: string): string
A uint through a .NET numeric specifier; large values stay positive.
stdlib/std/fmt.lyr:23
formatFloat function
pub fn formatFloat(value: float, spec: string): string
A float through a .NET numeric specifier (N2, F3, E2, P1, ...).
stdlib/std/fmt.lyr:25
formatBool function
pub fn formatBool(value: bool, spec: string): string
A bool through a .NET specifier.
stdlib/std/fmt.lyr:27
formatChar function
pub fn formatChar(value: char, spec: string): string
A char through a .NET specifier.
stdlib/std/fmt.lyr:29
formatString function
pub fn formatString(value: string, spec: string): string
A string at a width: padding on the right ({name:10}) or, with a leading minus, on the
left ({name:-10}).
stdlib/std/fmt.lyr:33
formatRadix function
pub fn formatRadix(value: int, radix: int): string
To a base from 2 to 36. Letters from a for digit values above 9.
The inverse of std.string.parseIntRadix. They live in different modules because parsing is
text processing and formatting is output, and std.string must not import std.fmt.
stdlib/std/fmt.lyr:48
formatHex function
pub fn formatHex(value: int): string
Hexadecimal, lower case, no prefix.
stdlib/std/fmt.lyr:82
formatBinary function
pub fn formatBinary(value: int): string
Binary, no prefix.
stdlib/std/fmt.lyr:87
formatOctal function
pub fn formatOctal(value: int): string
Octal, no prefix.
stdlib/std/fmt.lyr:92
formatHexPadded function
pub fn formatHexPadded(value: int, width: int): string
Hexadecimal with a fixed number of digits and leading zeros: formatHexPadded(255, 4) is
"00ff", for addresses and colour values where the width carries meaning.
stdlib/std/fmt.lyr:98
padLeft function
pub fn padLeft(value: string, width: int): string
Pads with spaces at the FRONT until width is reached; longer strings stay unchanged.
stdlib/std/fmt.lyr:105
padRight function
pub fn padRight(value: string, width: int): string
Pads with spaces at the END until width is reached; longer strings stay unchanged.
stdlib/std/fmt.lyr:110
center function
pub fn center(value: string, width: int): string
Centres. On an odd remainder the extra character goes to the RIGHT. A decision rather than a matter of course, but without it the same input yields two different results depending on the implementation.
stdlib/std/fmt.lyr:117
formatBytes function
pub fn formatBytes(bytes: int): string
Bytes in readable form: 1536 becomes "1.5 KB".
Base 1024 with the prefixes without i (KB rather than KiB), the spelling operating
systems and tools actually use.
stdlib/std/fmt.lyr:132
table function
pub fn table(rows: string[][], separator: string): string
Aligns columns. Each row is a string[]; short rows are padded with empty cells.
No borders and no header handling: what a table means is the caller's business. This does the tedious part — two passes over the data, to know the column widths before printing.
stdlib/std/fmt.lyr:156