2015-10-06 17:01 GMT+03:00 Johannes Schlüter <johan...@schlueters.de>:
> On Tue, 2015-10-06 at 15:42 +0400, somebody anon wrote: > > Please fix your mail program to provide a name and In-Reply-To and > References headers so that we can address somebody and your mails are > sorted correctly. > > > I've implemented this function and two other size-related in php [1], > but I > > think they should be in php core to avoid implementation of them by > > thousands of people. This draft is only for demonstation purposes. There > > are presented three functions: > > > > a. size_format([$format,] $bytes [, $unit]): string > > If we do it this must be generic and work for "everybody". This is not > trivial. i.e. for 1001 bytes depending on context any of these might be > "correct": > * 1001 byte > * 0.98 KiB > * 0.98 kB > * 0,98 kB > * 1 KiB > * 1 KB > * 1 Ko > * ... > Not all of them are correct. 0.98 kB for 1001 b is not correct, for example. But with current behavior I got these results without any modification of source code: "1001 b" "0.98 KiB" "0.98 kb" "1.00 kb" "1 KiB" "100 MiB" "1.44 MiB" > Also one often wants different precision depending on the value > * 100 MB (not 100.23 MB) > * 1.44 MB (not 1 MB) > > Feel free to come back with a more complete proposal and provide a name, > a proper subject etc. (... and even then I doubt this has to be part of > the core distribution, we should only add things which can't be done in > userland (due to libraries or performance requirements or similar) as > userland code is more flexible to change/improve and simpler to debug > for users and especially with PHP 7 fast enough for mot things) > I don't think that some people prefer kB. Also, what "ko" is? > > johannes > >