]> granicus.if.org Git - php/commitdiff
added iconv_set_encoding() to change the encoding setting.
authorRui Hirokawa <hirokawa@php.net>
Mon, 8 Jan 2001 02:39:52 +0000 (02:39 +0000)
committerRui Hirokawa <hirokawa@php.net>
Mon, 8 Jan 2001 02:39:52 +0000 (02:39 +0000)
ext/standard/basic_functions.c
ext/standard/php_string.h
ext/standard/string.c

index da694a48d4f93b3223da1fd124f4328a8020fc36..a59ed605f7e099c8a536adc28dff305f7347e991 100644 (file)
@@ -197,6 +197,7 @@ function_entry basic_functions[] = {
 #ifdef HAVE_ICONV
     PHP_FE(iconv,                                                                      NULL)
     PHP_FE(ob_iconv_handler,                                           NULL)
+    PHP_FE(iconv_set_encoding,                                         NULL)
 #endif
        PHP_FE(parse_url,                                                               NULL)
        PHP_FE(urlencode,                                                               NULL)
index da8a568954e55236bf24a078bad7eb6ce37f5f0b..ce6fce4a82bfd1581bb8e480b00c70cbdd5ca194 100644 (file)
@@ -80,6 +80,7 @@ PHP_FUNCTION(str_pad);
 PHP_FUNCTION(sscanf);
 PHP_FUNCTION(iconv);
 PHP_FUNCTION(ob_iconv_handler);
+PHP_FUNCTION(iconv_set_encoding);
 
 #define strnatcmp(a, b) \
        strnatcmp_ex(a, strlen(a), b, strlen(b), 0)
index 34dc4cf6e471a8ba5406e767b05d839db0d3c869..b422cf94c3fe1e970c0c6e0de50e01750477400e 100644 (file)
@@ -3050,7 +3050,6 @@ PHP_FUNCTION(iconv)
     zval **in_charset, **out_charset, **in_buffer;
     unsigned int in_size, out_size;
     char *out_buffer, *in_p, *out_p;
-    iconv_t cd;
     size_t result;
     typedef unsigned int ucs4_t;
 
@@ -3096,6 +3095,33 @@ PHP_FUNCTION(ob_iconv_handler)
        
 }
 
+/* {{{ proto bool iconv_set_encoding(string int_charset, string out_charset)
+   set internal encoding and output encoding for ob_iconv_handler().
+*/
+PHP_FUNCTION(iconv_set_encoding)
+{
+    zval **int_charset, **out_charset;
+
+    if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &int_charset, &out_charset) == FAILURE) {
+        WRONG_PARAM_COUNT;
+    }
+
+    convert_to_string_ex(int_charset);
+    convert_to_string_ex(out_charset);
+
+       if (BG(iconv_internal_encoding)) {
+               free(BG(iconv_internal_encoding));
+       }
+       BG(iconv_internal_encoding) = estrndup(Z_STRVAL_PP(int_charset),Z_STRLEN_PP(int_charset));
+
+       if (BG(iconv_output_encoding)) {
+               free(BG(iconv_output_encoding));
+       }
+       BG(iconv_output_encoding) = estrndup(Z_STRVAL_PP(out_charset),Z_STRLEN_PP(out_charset));
+
+       RETURN_TRUE;
+}
+
 #endif
 
 /*