Edit report at https://pear.php.net/bugs/bug.php?id=21070&edit=1

  ID: 21070
  Comment by: pear@0xdecafbad.com
  Reported By: pear@0xdecafbad.com
  Summary: Cannot calculateTotalsFor() with colorized text
  Status: Open
  Type: Bug
  Package: Console_Table
  Operating System: ubuntu
  Package Version: 1.3.0
  PHP Version: 5.5.18
  Roadmap Versions:
  New Comment:

I only added this to this bug because its the same fundamental problem
(non numbers in the array post filter), although different enough it may
do well with its own thread. This occurred to me at this point and not
before my comment. I will create a new bug report/feature request for
the formatted number problem.

Previous Comments:

[2016-05-31 12:17:22] bmcdanel

To make this work even better perhaps something like this would be
helpful to add.

unformat a number that has been formatted with number_format()

This is less trivial and I am unsure of the code submission process
especially for code that is not mine so I am reluctant to apply it,
however it seems to me that numbers might often be formatted with a
filter before they are summed at the end.


[2016-05-31 08:56:34] bmcdanel

Colorized text (Console_Color2) adds escape characters.
calculateTotalsFor() does not strip this

This would work if calculateTotalsFor() ran before the filters but
that would likely cause problems
for several use cases where data formatting is required (eg
2+2=5 for large values of 2).

I defined my table with "ansi color" = true. However that
function does not use it. To that end I
altered it:

Starting about line 504 in Table.php
                 foreach ($this->_calculateTotals as $columnID) {
                         if ($this->_ansiColor) {
                                $totals[$columnID] += $this->_ansiColor-
                         } else {
                                $totals[$columnID] += $row[$columnID];

Works for me. Should work for everyone.

Expected result:
for it to work

Actual result:
didnt work


Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppear-bugs @
postedMay 31, '16 at 4:16p
activeMay 31, '16 at 4:55p

1 user in discussion

Pear: 2 posts



site design / logo © 2022 Grokbase