diff options
| author | Wez Furlong <wez@php.net> | 2002-09-26 00:53:47 +0000 |
|---|---|---|
| committer | Wez Furlong <wez@php.net> | 2002-09-26 00:53:47 +0000 |
| commit | 1a87c6b5bf0d1bf7ff3b7b8ba571c9add77be308 (patch) | |
| tree | 092b416c6416968be48c75a7e60a0bec16fccb0e /ext/mbstring/mbstring.c | |
| parent | 2f418a1fdb4bbb0e589c48abf54251478a6974cb (diff) | |
| download | php-git-1a87c6b5bf0d1bf7ff3b7b8ba571c9add77be308.tar.gz | |
(PHP mb_convert_case) Add function that will convert the case of a string
Respecting it's encoding (or the internal encoding).
Diffstat (limited to 'ext/mbstring/mbstring.c')
| -rw-r--r-- | ext/mbstring/mbstring.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 49baf8091d..9a361936e7 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -64,6 +64,7 @@ #include "rfc1867.h" #include "php_content_types.h" #include "SAPI.h" +#include "php_unicode.h" #ifdef ZEND_MULTIBYTE #include "zend_multibyte.h" @@ -176,6 +177,7 @@ const struct def_mbctype_tbl mbctype_tbl[] = { #endif function_entry mbstring_functions[] = { + PHP_FE(mb_convert_case, NULL) PHP_FE(mb_language, NULL) PHP_FE(mb_internal_encoding, NULL) PHP_FE(mb_http_input, NULL) @@ -717,6 +719,9 @@ PHP_MINIT_FUNCTION(mbstring) REGISTER_LONG_CONSTANT("MB_OVERLOAD_STRING", MB_OVERLOAD_STRING, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("MB_OVERLOAD_REGEX", MB_OVERLOAD_REGEX, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MB_CASE_UPPER", PHP_UNICODE_CASE_UPPER, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MB_CASE_LOWER", PHP_UNICODE_CASE_LOWER, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("MB_CASE_TITLE", PHP_UNICODE_CASE_TITLE, CONST_CS | CONST_PERSISTENT); return SUCCESS; } @@ -2476,6 +2481,29 @@ PHP_FUNCTION(mb_convert_encoding) /* }}} */ +/* {{{ proto string mb_convert_case(string sourcestring, int mode [, string encoding]) + Returns a case-folded version of sourcestring */ +PHP_FUNCTION(mb_convert_case) +{ + char *str, *from_encoding = (char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding)); + long str_len, from_encoding_len; + long case_mode = 0; + char *newstr; + size_t ret_len; + + RETVAL_FALSE; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|s!", &str, &str_len, + &case_mode, &from_encoding, &from_encoding_len) == FAILURE) + RETURN_FALSE; + + newstr = php_unicode_convert_case(case_mode, str, str_len, &ret_len, from_encoding TSRMLS_CC); + + if (newstr) + RETVAL_STRINGL(newstr, ret_len, 0); + +} +/* }}} */ + /* {{{ proto string mb_detect_encoding(string str [, mixed encoding_list]) Encodings of the given string is returned (as a string) */ PHP_FUNCTION(mb_detect_encoding) |
