Skip to content

std.fmt proposal: improve format string syntax #19488

@HydroH

Description

@HydroH

Extracted from #14436 and #19473 .
Currently, std.fmt format string looks like this: [argument][specifier]:[fill][alignment][width].[precision].
It lacks the following capabilities when formatting numbers:

  • Ability to specify whether or not a positive sign should be shown before positive numbers;
  • Ability to pad the number with leading zeroes.

As mentioned here, formatting numbers with leading zeroes and padding strings with fill characters are very different things, and padding zeroes should probably deserve a separate option.
If the options for explicit signs and padding zeroes were introduces, what syntax should they be? What options could they provide?

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions