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

Commit

Permalink
Revert "Revert "Merge branch 'superdweebie-rand-bugfix'""
Browse files Browse the repository at this point in the history
This reverts commit b0ae4689135d62555cf9bbe55cdd7dddcd2d8f05 in order to allow
forward-porting fixes to develop.

Conflicts:
	library/Zend/ModuleManager/ModuleEvent.php
  • Loading branch information
Show file tree
Hide file tree
Showing 5 changed files with 2,163 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ abstract class AbstractAdapter implements AdapterInterface
*/
public function write($text, $color = null, $bgColor = null)
{
//Encode text to match console encoding
$text = $this->encodeText($text);

if ($color !== null || $bgColor !== null) {
echo $this->colorize($text, $color, $bgColor);
} else {
Expand Down Expand Up @@ -497,4 +500,27 @@ public function readChar($mask = null)
fclose($f);
return $char;
}

/**
* Encode a text to match console encoding
*
* @param string $text
* @return string the encoding text
*/
public function encodeText($text)
{
if ($this->isUtf8()) {
if (StringUtils::isValidUtf8($text)) {
return $text;
}

return utf8_encode($text);
}

if (StringUtils::isValidUtf8($text)) {
return utf8_decode($text);
}

return $text;
}
}
Loading

0 comments on commit 1b4ee9c

Please sign in to comment.