Skip to content

Commit 2381d2b

Browse files
committed
Use strwidth() instead of safe_strlen() on calcing widths.
1 parent d1085fa commit 2381d2b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/cli/Colors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static public function length($string) {
185185
$test_string = self::decolorize($string);
186186
}
187187

188-
return safe_strlen($test_string);
188+
return strwidth($test_string);
189189
}
190190

191191
/**

lib/cli/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function setRenderer(Renderer $renderer) {
102102
*/
103103
protected function checkRow(array $row) {
104104
foreach ($row as $column => $str) {
105-
$width = Colors::shouldColorize() ? Colors::length($str) : safe_strlen($str);
105+
$width = Colors::shouldColorize() ? Colors::length($str) : strwidth($str);
106106
if (!isset($this->_width[$column]) || $width > $this->_width[$column]) {
107107
$this->_width[$column] = $width;
108108
}

lib/cli/table/Ascii.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ public function row( array $row ) {
133133
$value = str_replace( PHP_EOL, ' ', $value );
134134

135135
$col_width = $this->_widths[ $col ];
136-
$original_val_width = Colors::shouldColorize() ? Colors::length( $value ) : \cli\safe_strlen( $value );
136+
$original_val_width = Colors::shouldColorize() ? Colors::length( $value ) : \cli\strwidth( $value );
137137
if ( $original_val_width > $col_width ) {
138138
$row[ $col ] = \cli\safe_substr( $value, 0, $col_width );
139139
$value = \cli\safe_substr( $value, $col_width, $original_val_width );
140140
$i = 0;
141141
do {
142142
$extra_value = \cli\safe_substr( $value, 0, $col_width );
143-
$val_width = \cli\safe_strlen( $extra_value );
143+
$val_width = \cli\strwidth( $extra_value );
144144
if ( $val_width ) {
145145
$extra_rows[ $col ][] = $extra_value;
146146
$value = \cli\safe_substr( $value, $col_width, $original_val_width );

0 commit comments

Comments
 (0)