]> granicus.if.org Git - php/commitdiff
Allow bidirectional encoding option via single context param
authorSara Golemon <pollita@php.net>
Fri, 24 Mar 2006 22:27:13 +0000 (22:27 +0000)
committerSara Golemon <pollita@php.net>
Fri, 24 Mar 2006 22:27:13 +0000 (22:27 +0000)
ext/standard/streamsfuncs.c

index 4d021aea3505276dc8a43bdfa97a93292d15fdb0..abdf00a0f2b8c01bb8d7d44771c7f8e19cd94bcb 100644 (file)
@@ -926,6 +926,20 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
        if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) {
                parse_context_options(context, *tmp TSRMLS_CC);
        }
+       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "encoding", sizeof("encoding"), (void**)&tmp)) {
+               zval strval = **tmp;
+
+               if (context->input_encoding) {
+                       efree(context->input_encoding);
+               }
+               if (context->output_encoding) {
+                       efree(context->output_encoding);
+               }
+               zval_copy_ctor(&strval);
+               convert_to_string(&strval);
+               context->input_encoding = Z_STRVAL(strval);
+               context->output_encoding = estrdup(Z_STRVAL(strval));
+       }
        if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "input_encoding", sizeof("input_encoding"), (void**)&tmp)) {
                zval strval = **tmp;