summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRui Hirokawa <hirokawa@php.net>2003-10-22 14:14:05 +0000
committerRui Hirokawa <hirokawa@php.net>2003-10-22 14:14:05 +0000
commit0ce637835a98f4b3e8826ea7c19792851027ed74 (patch)
tree468264c115b5ef0eabbd01ff14ee03b2aa8de095 /ext
parent980c3b2b4c6b6dffdb7057be111523e6e86c6ead (diff)
downloadphp-git-0ce637835a98f4b3e8826ea7c19792851027ed74.tar.gz
name/value in multipart/form-date will be converted into internal encoding when mbstring.encoding_translation is On.
Diffstat (limited to 'ext')
-rw-r--r--ext/mbstring/mbstring.c61
-rw-r--r--ext/mbstring/mbstring.h4
2 files changed, 42 insertions, 23 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index ab51a376c8..d0dd74602b 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -3327,9 +3327,10 @@ MBSTRING_API size_t php_mb_gpc_mbchar_bytes(const char *s TSRMLS_DC)
/* }}} */
/* {{{ MBSTRING_API int php_mb_gpc_encoding_converter() */
-MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, const char *encoding_to, const char *encoding_from
+MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, int num, const char *encoding_to, const char *encoding_from
TSRMLS_DC)
{
+ int i;
mbfl_string string, result, *ret;
enum mbfl_no_encoding from_encoding, to_encoding;
mbfl_buffer_converter *convd;
@@ -3358,36 +3359,40 @@ MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, const char
mbfl_string_init(&result);
string.no_encoding = from_encoding;
string.no_language = MBSTRG(current_language);
- string.val = (char*)(*str);
- string.len = *len;
- /* initialize converter */
- convd = mbfl_buffer_converter_new(from_encoding, to_encoding, string.len);
- if (convd == NULL) {
- return -1;
- }
- mbfl_buffer_converter_illegal_mode(convd, MBSTRG(current_filter_illegal_mode));
- mbfl_buffer_converter_illegal_substchar(convd, MBSTRG(current_filter_illegal_substchar));
+ for (i=0; i<num; i++){
+ string.val = (char*)str[i];
+ string.len = len[i];
- /* do it */
- ret = mbfl_buffer_converter_feed_result(convd, &string, &result);
- if (ret != NULL) {
- efree(*str);
- *str = ret->val;
- *len = ret->len;
+ /* initialize converter */
+ convd = mbfl_buffer_converter_new(from_encoding, to_encoding, string.len);
+ if (convd == NULL) {
+ return -1;
+ }
+ mbfl_buffer_converter_illegal_mode(convd, MBSTRG(current_filter_illegal_mode));
+ mbfl_buffer_converter_illegal_substchar(convd, MBSTRG(current_filter_illegal_substchar));
+
+ /* do it */
+ ret = mbfl_buffer_converter_feed_result(convd, &string, &result);
+ if (ret != NULL) {
+ efree(str[i]);
+ str[i] = ret->val;
+ len[i] = ret->len;
+ }
+ mbfl_buffer_converter_delete(convd);
}
- mbfl_buffer_converter_delete(convd);
return ret ? 0 : -1;
}
/* {{{ MBSTRING_API int php_mb_gpc_encoding_detector()
*/
-MBSTRING_API int php_mb_gpc_encoding_detector(const char *arg_string, int arg_length, char *arg_list TSRMLS_DC)
+MBSTRING_API int php_mb_gpc_encoding_detector(char **arg_string, int *arg_length, int num, char *arg_list TSRMLS_DC)
{
mbfl_string string;
enum mbfl_no_encoding *elist;
enum mbfl_no_encoding encoding;
+ mbfl_encoding_detector *identd = NULL;
int size, *list;
@@ -3418,9 +3423,23 @@ MBSTRING_API int php_mb_gpc_encoding_detector(const char *arg_string, int arg_le
mbfl_string_init(&string);
string.no_language = MBSTRG(current_language);
- string.val = (char*)arg_string;
- string.len = arg_length;
- encoding = mbfl_identify_encoding_no(&string, elist, size);
+
+ identd = mbfl_encoding_detector_new(elist, size);
+
+ if (identd) {
+ int n = 0;
+ while(n < num){
+ string.val = (unsigned char *)arg_string[n];
+ string.len = arg_length[n];
+ if (mbfl_encoding_detector_feed(identd, &string)) {
+ break;
+ }
+ n++;
+ }
+ encoding = mbfl_encoding_detector_judge(identd);
+ mbfl_encoding_detector_delete(identd);
+ }
+
if (encoding != mbfl_no_encoding_invalid) {
MBSTRG(http_input_identify) = encoding;
return SUCCESS;
diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h
index 646ee72e34..b396ac17a5 100644
--- a/ext/mbstring/mbstring.h
+++ b/ext/mbstring/mbstring.h
@@ -143,9 +143,9 @@ MBSTRING_API int php_mb_encoding_detector_ex(const char *arg_string, int arg_len
MBSTRING_API int php_mb_encoding_converter_ex(char **str, int *len, const char *encoding_to,
const char *encoding_from TSRMLS_DC);
-MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, const char *encoding_to, const char *encoding_from TSRMLS_DC);
+MBSTRING_API int php_mb_gpc_encoding_converter(char **str, int *len, int num, const char *encoding_to, const char *encoding_from TSRMLS_DC);
-MBSTRING_API int php_mb_gpc_encoding_detector(const char *arg_string, int arg_length, char *arg_list TSRMLS_DC);
+MBSTRING_API int php_mb_gpc_encoding_detector(char **arg_string, int *arg_length, int num, char *arg_list TSRMLS_DC);
ZEND_BEGIN_MODULE_GLOBALS(mbstring)
enum mbfl_no_language language;