public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/28943] New: printf field width specifier is inconsistent between %d and %f for multibyte output
@ 2022-03-04  8:12 fweimer at redhat dot com
  2022-03-04  8:44 ` [Bug stdio/28943] " fweimer at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2022-03-04  8:12 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=28943

            Bug ID: 28943
           Summary: printf field width specifier is inconsistent between
                    %d and %f for multibyte output
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: fweimer at redhat dot com
  Target Milestone: ---

With the ' and I flags, numeric conversions can include non-ASCII multibyte
characters. Presently, field width is handled differently for %f and %d
conversions. In %f conversions, the width is based on the number of
digits/separators before output encoding (each has width 1), with %d, width is
based on bytes.

POSIX.1-2017 says:

“
An optional minimum field width.  If the converted value has fewer bytes than
the field width, it shall be padded with <space> characters by default on the
left; it shall be padded on the right if the left-adjustment flag ('-'),
described below, is given to the field width.
”

Which suggests the %d behavior. (POSIX only specifies ', but not I.) But this
makes printf inconsistent with wprintf. Counting bytes is also seems not very
useful for the column adjustments of numbers, particularly combined with
localization. So I think glibc should adopt character counts, not byte counts.

This only applies to the numeric conversions; for (non-wide) strings, field
width should continue to be measured in bytes, not multibyte characters.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-25 14:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04  8:12 [Bug stdio/28943] New: printf field width specifier is inconsistent between %d and %f for multibyte output fweimer at redhat dot com
2022-03-04  8:44 ` [Bug stdio/28943] " fweimer at redhat dot com
2022-05-23  9:08 ` cvs-commit at gcc dot gnu.org
2023-02-06 17:42 ` carlos at redhat dot com
2023-09-25 12:39 ` fweimer at redhat dot com
2023-09-25 13:50 ` vincent-srcware at vinc17 dot net
2024-03-25 14:34 ` schwab@linux-m68k.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).