masugata Thu Mar 16 15:21:12 2006 UTC
Modified files:
/php-src/ext/mbstring mbstring.c
Log:
added option parameter mb_list_encodings( ).
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.243&r2=1.244&diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.243
php-src/ext/mbstring/mbstring.c:1.244
--- php-src/ext/mbstring/mbstring.c:1.243 Sun Mar 12 07:54:03 2006
+++ php-src/ext/mbstring/mbstring.c Thu Mar 16 15:21:12 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.243 2006/03/12 07:54:03 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.244 2006/03/16 15:21:12 masugata Exp $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -2314,19 +2314,41 @@
}
/* }}} */
-/* {{{ proto array mb_list_encodings()
- Returns an array of all supported encodings */
+/* {{{ proto mixed mb_list_encodings([string alias_encoding])
+ Returns an array of all supported entity encodings or Returns the entity
encoding as a string */
PHP_FUNCTION(mb_list_encodings)
{
const mbfl_encoding **encodings;
const mbfl_encoding *encoding;
+ enum mbfl_no_encoding no_encoding;
int i;
+ char *name = NULL;
+ int name_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name,
&name_len) == FAILURE) {
+ RETURN_FALSE;
+ }
- array_init(return_value);
- i = 0;
- encodings = mbfl_get_supported_encodings();
- while ((encoding = encodings[i++]) != NULL) {
- add_next_index_string(return_value, (char *) encoding->name, 1);
+ if (name == NULL) {
+ array_init(return_value);
+ i = 0;
+ encodings = mbfl_get_supported_encodings();
+ while ((encoding = encodings[i++]) != NULL) {
+ add_next_index_string(return_value, (char *)
encoding->name, 1);
+ }
+ } else {
+ no_encoding = mbfl_name2no_encoding(name);
+ if (no_encoding == mbfl_no_encoding_invalid) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown
encoding \"%s\"", name);
+ RETURN_FALSE;
+ }
+
+ name = (char *)mbfl_no_encoding2name(no_encoding);
+ if (name != NULL) {
+ RETURN_STRING(name, 1);
+ } else {
+ RETURN_FALSE;
+ }
}
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php