Issues

ZF-11792: Unicode characters break multi-row columns

Issue Type: Bug Created: 2011-10-03T00:14:24.000+0000 Last Updated: 2011-10-08T20:57:48.000+0000 Status: Resolved Fix version(s): Reporter: Nico Nägele (peaceman) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Text_Table

Related issues: Attachments: - zend-table-test.patch

Description

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:

<pre class="highlight">
$table = new Zend_Text_Table(array('columnWidths' => array(5, 5)));
$table->appendRow(array('alohaaa', 'dö'));

Example output:

<pre class="highlight">
┌─────┬─────┐
│aloha│dö   │
│aa   │      │
└─────┴─────┘

Comments

Posted by Nico Nägele (peaceman) on 2011-10-08T17:27:12.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts