[Console] Selectively output to STDOUT or OUTPUT stream
Addresses issues with writing console output for IBM i5 Series (OS400). The normal QP2TERM shell outputs garbage text when attempting to write directly to STDOUT, likely because of EBCDIC character-encoding used on IBM platforms. Writing to the OUTPUT mimics using 'echo' or 'print' and prints properly in the console. Fixes #1434
This commit is contained in:
parent
195a1d36c0
commit
5b92b9ed43
@ -42,6 +42,26 @@ class ConsoleOutput extends StreamOutput
|
||||
*/
|
||||
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated, $formatter);
|
||||
$outputStream = 'php://stdout';
|
||||
if (!$this->hasStdoutSupport()) {
|
||||
$outputStream = 'php://output';
|
||||
}
|
||||
|
||||
parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current environment supports writing console output to
|
||||
* STDOUT.
|
||||
*
|
||||
* IBM iSeries (OS400) exhibits character-encoding issues when writing to
|
||||
* STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage
|
||||
* output.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function hasStdoutSupport()
|
||||
{
|
||||
return ('OS400' != php_uname('s'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user