Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Updated consumers after API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-mabe committed Dec 31, 2012
1 parent 92981fa commit d954b18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/Figlet/Figlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,16 @@ public function render($text, $encoding = 'UTF-8')
}

// Get the string wrapper supporting UTF-8 character encoding and the input encoding
$strWrapper = StringUtils::getWrapper('UTF-8', $encoding);
$strWrapper = StringUtils::getWrapper($encoding, 'UTF-8');

// Convert $text to UTF-8 and check encoding
$text = $strWrapper->convert($text, 'UTF-8', $encoding);
$text = $strWrapper->convert($text);
if (!StringUtils::isValidUtf8($text)) {
throw new Exception\UnexpectedValueException('$text is not encoded with ' . $encoding);
}

$strWrapper = StringUtils::getWrapper('UTF-8');

$this->output = '';
$this->outputLine = array();

Expand All @@ -433,14 +435,14 @@ public function render($text, $encoding = 'UTF-8')

$wordBreakMode = 0;
$lastCharWasEol = false;
$textLength = $strWrapper->strlen($text, 'UTF-8');
$textLength = $strWrapper->strlen($text);

for ($charNum = 0; $charNum < $textLength; $charNum++) {
// Handle paragraphs
$char = $strWrapper->substr($text, $charNum, 1, 'UTF-8');
$char = $strWrapper->substr($text, $charNum, 1);

if ($char === "\n" && $this->handleParagraphs && !$lastCharWasEol) {
$nextChar = $strWrapper->substr($text, ($charNum + 1), 1, 'UTF-8');
$nextChar = $strWrapper->substr($text, ($charNum + 1), 1);
if (!$nextChar) {
$nextChar = null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/MultiByte.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function wordWrap($string, $width = 75, $break = "\n", $cut = fals
), E_USER_DEPRECATED);

try {
return StringUtils::getWrapper($charset)->wordWrap($string, $width, $break, $cut, $charset);
return StringUtils::getWrapper($charset)->wordWrap($string, $width, $break, $cut);
} catch (\Zend\Stdlib\Exception\InvalidArgumentException $e) {
throw new Exception\InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
Expand All @@ -63,6 +63,6 @@ public static function strPad($input, $padLength, $padString = ' ', $padType = \
'Zend\Stdlib\StringUtils::getWrapper(<charset>)->strPad'
), E_USER_DEPRECATED);

return StringUtils::getWrapper($charset)->strPad($input, $padLength, $padString, $padType, $charset);
return StringUtils::getWrapper($charset)->strPad($input, $padLength, $padString, $padType);
}
}
8 changes: 4 additions & 4 deletions src/Table/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function setContent($content, $charset = null)
if (PHP_OS !== 'AIX') {
// AIX does not understand these character sets
$strWrapper = StringUtils::getWrapper($inputCharset, $outputCharset);
$content = $strWrapper->convert($content, $outputCharset, $inputCharset);
$content = $strWrapper->convert($content);
}

}
Expand Down Expand Up @@ -206,12 +206,12 @@ public function render($columnWidth, $padding = 0)

$outputCharset = Table::getOutputCharset();
$strWrapper = StringUtils::getWrapper($outputCharset);
$lines = explode("\n", $strWrapper->wordWrap($this->content, $columnWidth, "\n", true, $outputCharset));
$lines = explode("\n", $strWrapper->wordWrap($this->content, $columnWidth, "\n", true));
$paddedLines = array();

foreach ($lines AS $line) {
foreach ($lines as $line) {
$paddedLines[] = str_repeat(' ', $padding)
. $strWrapper->strPad($line, $columnWidth, ' ', $padMode, $outputCharset)
. $strWrapper->strPad($line, $columnWidth, ' ', $padMode)
. str_repeat(' ', $padding);
}

Expand Down

0 comments on commit d954b18

Please sign in to comment.