Another (and hopefully last) major streams commit.

This moves unicode conversion to the filter layer
(rather than at the lower streams layer)
unicode_filter.c has been moved from ext/unicode to main/streams
as it's an integral part of the streams unicode conversion process.

There are now three ways to set encoding on a stream:

(1) By context
$ctx = stream_context_create(NULL,array('encoding'=>'latin1'));
$fp = fopen('somefile', 'r+t', false, $ctx);

(2) By stream_encoding()
$fp = fopen('somefile', 'r+');
stream_encoding($fp, 'latin1');

(3) By filter
$fp = fopen('somefile', 'r+');
stream_filter_append($fp, 'unicode.from.latin1', STREAM_FILTER_READ);
stream_filter_append($fp, 'unicode.to.latin1', STREAM_FILTER_WRITE);

Note: Methods 1 and 2 are convenience wrappers around method 3.
This commit is contained in:
Sara Golemon 2006-03-29 01:20:43 +00:00
parent f028fcecb5
commit 30a2bd1d11
15 changed files with 275 additions and 238 deletions

View file

@ -273,10 +273,6 @@ ZEND_GET_MODULE(unicode)
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(unicode)
{
if (php_stream_filter_register_factory("unicode.*", &php_unicode_filter_factory TSRMLS_CC) == FAILURE) {
return FAILURE;
}
php_register_unicode_iterators(TSRMLS_C);
php_init_collation(TSRMLS_C);
@ -287,9 +283,6 @@ PHP_MINIT_FUNCTION(unicode)
/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(unicode)
{
if (php_stream_filter_unregister_factory("unicode.*" TSRMLS_CC) == FAILURE) {
return FAILURE;
}
/* add your stuff here */