From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B67923858C20; Fri, 4 Mar 2022 08:12:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B67923858C20 From: "fweimer at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug stdio/28943] New: printf field width specifier is inconsistent between %d and %f for multibyte output Date: Fri, 04 Mar 2022 08:12:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: stdio X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fweimer at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2022 08:12:20 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28943 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: =E2=80=9C An optional minimum field width. If the converted value has fewer bytes th= an the field width, it shall be padded with characters by default on t= he left; it shall be padded on the right if the left-adjustment flag ('-'), described below, is given to the field width. =E2=80=9D Which suggests the %d behavior. (POSIX only specifies ', but not I.) But th= is makes printf inconsistent with wprintf. Counting bytes is also seems not ve= ry useful for the column adjustments of numbers, particularly combined with localization. So I think glibc should adopt character counts, not byte coun= ts. This only applies to the numeric conversions; for (non-wide) strings, field width should continue to be measured in bytes, not multibyte characters. --=20 You are receiving this mail because: You are on the CC list for the bug.=