note 49532 deleted from function.sprintf by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 10:14:33 +0000 |
| Subject: | note 49532 deleted from function.sprintf by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196928@lists.php.net to get a copy of this message | ||
Note Submitter: downright at comcast dot net
----
Just thought I'd give a heads up for anyone doing cross platform applications.
sprintf spacing is different numerically with Windows and Linux.
Linux aligned correctly:
$ol = sprintf ("%-6s|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f\n",
Windows aligned correctly:
$ol = sprintf ("%-6s|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f\n",
As you can see the strings are fine for spacing, however, the numbers need a difference of 3 in
order to have the same amount of spaces.
I noticed this after using sprintf to format a header for a web app I was working on. On windows it
fit, however, when it came to linux it was MUCH larger than the header.