php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80806 printf does not properly align columns when extended ascii characters like µ
Submitted: 2021-02-27 03:42 UTC Modified: 2021-02-27 04:03 UTC
From: smcbride at msn dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 7.4.15 OS: OpenSuse Tumbleweed
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: smcbride at msn dot com
New email:
PHP Version: OS:

 

 [2021-02-27 03:42 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-27 04:03 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: Unknown/Other Function +Package: Strings related
 [2021-02-27 04:03 UTC] requinix@php.net
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.
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Feb 03 11:03:46 2023 UTC