Skip to content

numfmt: does not honor LC_NUMERIC for decimal separator (input and output) #11927

@sylvestre

Description

@sylvestre

uutils numfmt always uses . as the decimal separator, regardless of LC_NUMERIC. GNU honors the locale for both formatting output and parsing input.

Output differs

$ LC_NUMERIC=fr_FR.UTF-8 /usr/bin/numfmt --to=iec 1500
1,5K

$ LC_NUMERIC=fr_FR.UTF-8 target/debug/coreutils numfmt --to=iec 1500
1.5K

Same with an explicit format:

$ LC_NUMERIC=fr_FR.UTF-8 /usr/bin/numfmt --to=iec --format=%-17.5f -- 310174
302,90500K

$ LC_NUMERIC=fr_FR.UTF-8 target/debug/coreutils numfmt --to=iec --format=%-17.5f -- 310174
302.90430K

(The digit difference there is tracked separately in #11926 — this issue is strictly about the . vs ,.)

Input parsing differs

GNU switches the input parser to the locale separator as well:

$ LC_NUMERIC=fr_FR.UTF-8 /usr/bin/numfmt --format=%.3f 1.5
numfmt: suffixe incorrect en entrée : '1.5'

$ LC_NUMERIC=fr_FR.UTF-8 /usr/bin/numfmt --format=%.3f 1,5
1,500

uutils accepts 1.5 in any locale and never accepts 1,5:

$ LC_NUMERIC=fr_FR.UTF-8 target/debug/coreutils numfmt --format=%.3f 1.5
1.500
$ LC_NUMERIC=fr_FR.UTF-8 target/debug/coreutils numfmt --format=%.3f 1,5
numfmt: invalid number: '1,5'

Expected

Match GNU: when LC_NUMERIC (or LC_ALL) names a locale whose decimal separator is ,, both the parser and the formatter should use ,.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions