encoding() public method

Sets the character set for stream encoding if possible. The stream_encoding function is not guaranteed to be available as it is seems as if it's experimental or just not officially documented. If the function is not available returns false.
public encoding ( string $charset ) : boolean
$charset string
return boolean Returns `false` if `stream_encoding()` function does not exist, boolean result of `stream_encoding()` otherwise.
コード例 #1
0
ファイル: StreamTest.php プロジェクト: WarToaster/HangOn
 public function testEncoding()
 {
     $stream = new Stream($this->_testConfig);
     $result = $stream->open();
     $stream->encoding('UTF-8');
     $result = $stream->resource();
     $this->assertTrue(is_resource($result));
     $stream = new Stream($this->_testConfig + array('encoding' => 'UTF-8'));
     $result = $stream->open();
     $result = $stream->resource();
     $this->assertTrue(is_resource($result));
 }
コード例 #2
0
ファイル: StreamTest.php プロジェクト: unionofrad/lithium
 public function testEncoding()
 {
     $stream = new Stream($this->_testConfig);
     $result = $stream->open();
     $stream->encoding('UTF-8');
     $result = $stream->resource();
     $this->assertInternalType('resource', $result);
     $stream = new Stream($this->_testConfig + array('encoding' => 'UTF-8'));
     $result = $stream->open();
     $result = $stream->resource();
     $this->assertInternalType('resource', $result);
 }