cvs: php4 /ext/standard basic_functions.c php_string.h string.c
| From: | Rui Hirokawa | Date: | Mon, 08 Jan 2001 02:39:52 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c php_string.h string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-3431@lists.php.net to get a copy of this message | ||
hirokawa Sun Jan 7 18:39:52 2001 EDT
Modified files:
/php4/ext/standard basic_functions.c php_string.h string.c
Log:
added iconv_set_encoding() to change the encoding setting.
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.292 php4/ext/standard/basic_functions.c:1.293
--- php4/ext/standard/basic_functions.c:1.292 Sun Jan 7 17:40:33 2001
+++ php4/ext/standard/basic_functions.c Sun Jan 7 18:39:52 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.292 2001/01/08 01:40:33 hirokawa Exp $ */
+/* $Id: basic_functions.c,v 1.293 2001/01/08 02:39:52 hirokawa Exp $ */
#include "php.h"
#include "php_main.h"
@@ -197,6 +197,7 @@
#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: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.29 php4/ext/standard/php_string.h:1.30
--- php4/ext/standard/php_string.h:1.29 Sun Jan 7 17:40:33 2001
+++ php4/ext/standard/php_string.h Sun Jan 7 18:39:52 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_string.h,v 1.29 2001/01/08 01:40:33 hirokawa Exp $ */
+/* $Id: php_string.h,v 1.30 2001/01/08 02:39:52 hirokawa Exp $ */
/* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
@@ -80,6 +80,7 @@
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: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.178 php4/ext/standard/string.c:1.179
--- php4/ext/standard/string.c:1.178 Sun Jan 7 17:40:33 2001
+++ php4/ext/standard/string.c Sun Jan 7 18:39:52 2001
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.178 2001/01/08 01:40:33 hirokawa Exp $ */
+/* $Id: string.c,v 1.179 2001/01/08 02:39:52 hirokawa Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -3050,7 +3050,6 @@
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;
@@ -3094,6 +3093,33 @@
zval_copy_ctor(return_value);
}
+}
+
+/* {{{ 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