Bug #80806 [Opn->Nab]: printf does not properly align columns when extended ascii characters like µ

From: Date: Sat, 27 Feb 2021 04:03:24 +0000
Subject: Bug #80806 [Opn->Nab]: printf does not properly align columns when extended ascii characters like µ
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232410@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80806&edit=1

 ID:                 80806
 Updated by:         requinix@php.net
 Reported by:        smcbride at msn dot com
 Summary:            printf does not properly align columns when extended
                     ascii characters like µ
-Status:             Open
+Status:             Not a bug
 Type:               Bug
-Package:            Unknown/Other Function
+Package:            Strings related
 Operating System:   OpenSuse Tumbleweed
 PHP Version:        7.4.15
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

https://www.php.net/manual/en/function.printf.php
> Warning
> Attempting to use a combination of the string and width specifiers with
> character sets that require more than one byte per character may result in
> unexpected results.


Previous Comments:
------------------------------------------------------------------------
[2021-02-27 03:42:35] smcbride at msn dot com

Description:
------------
When using a character like µ, printf is off by 1 character in length.  It is shorter that 15s.

printf("%-50s %15s %15s %15s %15s %15s" . PHP_EOL, "Function", "Num
Calls", "Avg Time (µs)", "Sum Time (µs)", "Min Time
(µs)", "Max Time (µs)");

Test script:
---------------
printf("%-50s %15s %15s %15s %15s %15s" . PHP_EOL, "Function", "Num
Calls", "Avg Time (µs)", "Sum Time (µs)", "Min Time
(µs)", "Max Time (µs)");

Expected result:
----------------
Expect it to be the correct spacing



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80806&edit=1


Thread (2 messages)

« previous php.bugs (#232410) next »