Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function renderCell($contents, $alignment, $width)
break;
}

return str_pad($contents, $width, ' ', $type);
return $this->mb_str_pad($contents, $width, ' ', $type);
}

protected function calculateWidths()
Expand All @@ -130,7 +130,7 @@ protected function calculateWidths()

foreach (array_merge([$this->headers], $this->rows) as $row) {
for ($i = 0; $i < count($row); $i++) {
$iWidth = strlen((string)$row[$i]);
$iWidth = mb_strlen((string)$row[$i]);
if (( ! array_key_exists($i, $widths)) || $iWidth > $widths[$i]) {
$widths[$i] = $iWidth;
}
Expand Down Expand Up @@ -178,5 +178,12 @@ protected function columnAlign($columnNumber)
return 'L';
}


}
protected function mb_str_pad($input, $pad_length, $pad_string, $pad_style, $encoding = "UTF-8") {
return str_pad(
$input,
strlen($input) - mb_strlen($input, $encoding) + $pad_length,
$pad_string,
$pad_style
);
}
}