ZF-11792: Unicode characters break multi-row columns


If you create a Zend_Text_Table object with 2 columns and the value of the first row in the first column is longer than the columns maximum width, the value is cutted and continued on the next line. So the second line of the second column has to be filled with spaces and the amount of spaces is calculated with strlen. Under the circumstance that the value of the second column contains an unicode character, strlen returns the wrong value and the table outputted is incorrect.

The miscalculation is happening in Zend/Text/Table/Row.php on line 204.

Example code:

$table = new Zend_Text_Table(array('columnWidths' => array(5, 5)));
$table->appendRow(array('alohaaa', 'dö'));

Example output:

│aloha│dö   │
│aa   │      │


A patch that fixes this issue and a new unit test method.