lithium\net\socket\Stream::encoding PHP Method

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.
    public function encoding($charset)
    {
        if (!function_exists('stream_encoding')) {
            return false;
        }
        return is_resource($this->_resource) ? stream_encoding($this->_resource, $charset) : false;
    }

Usage Example

Example #1
0
 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));
 }
All Usage Examples Of lithium\net\socket\Stream::encoding