]> granicus.if.org Git - php/commitdiff
Implement RFC https://wiki.php.net/rfc/default_encoding
authorYasuo Ohgaki <yohgaki@php.net>
Thu, 13 Feb 2014 02:54:52 +0000 (11:54 +0900)
committerYasuo Ohgaki <yohgaki@php.net>
Thu, 13 Feb 2014 02:54:52 +0000 (11:54 +0900)
34 files changed:
ext/iconv/iconv.c
ext/iconv/php_iconv.h
ext/iconv/tests/iconv_ini_encoding.phpt [new file with mode: 0644]
ext/iconv/tests/iconv_set_encoding_variation.phpt
ext/mbstring/mbstring.c
ext/mbstring/tests/ini_encoding.phpt [new file with mode: 0644]
ext/standard/html.c
main/SAPI.h
main/main.c
main/php.h
main/php_globals.h
php.ini-development
php.ini-production
sapi/cgi/tests/010.phpt
sapi/cgi/tests/011.phpt
sapi/cli/tests/bug43177.phpt
sapi/cli/tests/bug65066_100.phpt
sapi/cli/tests/bug65066_422.phpt
sapi/cli/tests/bug65066_511.phpt
sapi/cli/tests/bug65633.phpt
sapi/cli/tests/php_cli_server_004.phpt
sapi/cli/tests/php_cli_server_005.phpt
sapi/cli/tests/php_cli_server_006.phpt
sapi/cli/tests/php_cli_server_007.phpt
sapi/cli/tests/php_cli_server_008.phpt
sapi/cli/tests/php_cli_server_009.phpt
sapi/cli/tests/php_cli_server_010.phpt
sapi/cli/tests/php_cli_server_012.phpt
sapi/cli/tests/php_cli_server_015.phpt
sapi/cli/tests/php_cli_server_017.phpt
sapi/cli/tests/php_cli_server_018.phpt
sapi/cli/tests/php_cli_server_019.phpt
sapi/cli/tests/upload_2G.phpt
tests/basic/encoding.phpt [new file with mode: 0644]

index ea6ac1a1f16401c6add02b463f3abe231f588c6d..87ad5eeaab0c054615db7cb1b2d307806002d7db 100644 (file)
@@ -220,21 +220,55 @@ static char _generic_superset_name[] = ICONV_UCS4_ENCODING;
 #define GENERIC_SUPERSET_NBYTES 4
 /* }}} */
 
-static PHP_INI_MH(OnUpdateStringIconvCharset)
+
+static PHP_INI_MH(OnUpdateInputEncoding)
+{
+       if (new_value_length >= ICONV_CSNMAXLEN) {
+               return FAILURE;
+       }
+       if (new_value_length) {
+               OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       } else {
+               OnUpdateString(entry, PG(input_encoding), strlen(PG(input_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       }
+       return SUCCESS;
+}
+
+
+static PHP_INI_MH(OnUpdateOutputEncoding)
 {
        if(new_value_length >= ICONV_CSNMAXLEN) {
                return FAILURE;
        }
-       OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       if (new_value_length) {
+               OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       } else {
+               OnUpdateString(entry, PG(output_encoding), strlen(PG(output_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       }
        return SUCCESS;
 }
 
+
+static PHP_INI_MH(OnUpdateInternalEncoding)
+{
+       if(new_value_length >= ICONV_CSNMAXLEN) {
+               return FAILURE;
+       }
+       if (new_value_length) {
+               OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       } else {
+               OnUpdateString(entry, PG(internal_encoding), strlen(PG(internal_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       }
+       return SUCCESS;
+}
+
+
 /* {{{ PHP_INI
  */
 PHP_INI_BEGIN()
-       STD_PHP_INI_ENTRY("iconv.input_encoding",    ICONV_INPUT_ENCODING,    PHP_INI_ALL, OnUpdateStringIconvCharset, input_encoding,    zend_iconv_globals, iconv_globals)
-       STD_PHP_INI_ENTRY("iconv.output_encoding",   ICONV_OUTPUT_ENCODING,   PHP_INI_ALL, OnUpdateStringIconvCharset, output_encoding,   zend_iconv_globals, iconv_globals)
-       STD_PHP_INI_ENTRY("iconv.internal_encoding", ICONV_INTERNAL_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, internal_encoding, zend_iconv_globals, iconv_globals)
+       STD_PHP_INI_ENTRY("iconv.input_encoding",    "", PHP_INI_ALL, OnUpdateInputEncoding,    input_encoding,    zend_iconv_globals, iconv_globals)
+       STD_PHP_INI_ENTRY("iconv.output_encoding",   "", PHP_INI_ALL, OnUpdateOutputEncoding,   output_encoding,   zend_iconv_globals, iconv_globals)
+       STD_PHP_INI_ENTRY("iconv.internal_encoding", "", PHP_INI_ALL, OnUpdateInternalEncoding, internal_encoding, zend_iconv_globals, iconv_globals)
 PHP_INI_END()
 /* }}} */
 
index 26e3f3b2a614c7fef88059b9e69137f694a0de42..1389d7a993601b9fa5475c7761baa6afcb667b0f 100644 (file)
@@ -79,15 +79,9 @@ ZEND_END_MODULE_GLOBALS(iconv)
 #endif
 
 #ifdef HAVE_IBM_ICONV
-# define ICONV_INPUT_ENCODING "ISO8859-1"
-# define ICONV_OUTPUT_ENCODING "ISO8859-1"
-# define ICONV_INTERNAL_ENCODING "ISO8859-1"
 # define ICONV_ASCII_ENCODING "IBM-850"
 # define ICONV_UCS4_ENCODING "UCS-4"
 #else
-# define ICONV_INPUT_ENCODING "ISO-8859-1"
-# define ICONV_OUTPUT_ENCODING "ISO-8859-1"
-# define ICONV_INTERNAL_ENCODING "ISO-8859-1"
 # define ICONV_ASCII_ENCODING "ASCII"
 # define ICONV_UCS4_ENCODING "UCS-4LE"
 #endif
diff --git a/ext/iconv/tests/iconv_ini_encoding.phpt b/ext/iconv/tests/iconv_ini_encoding.phpt
new file mode 100644 (file)
index 0000000..b9a6982
--- /dev/null
@@ -0,0 +1,68 @@
+--TEST--
+Encoding INI test
+--SKIPIF--
+<?php extension_loaded('iconv') or die('skip mbstring not available'); ?>
+--INI--
+default_charset=ISO-8859-1
+internal_encoding=
+input_encoding=
+output_encoding=
+iconv.internal_encoding=ISO-8859-1
+iconv.http_input=ISO-8859-1
+iconv.http_output=ISO-8859-1
+--FILE--
+<?php
+echo "Getting INI\n";
+var_dump(ini_get('default_charset'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('output_encoding'));
+
+var_dump(ini_get('iconv.internal_encoding'));
+var_dump(ini_get('iconv.input_encoding'));
+var_dump(ini_get('iconv.output_encoding'));
+
+echo "Setting INI\n";
+var_dump(ini_set('default_charset', 'UTF-8'));
+var_dump(ini_set('internal_encoding', 'UTF-8'));
+var_dump(ini_set('input_encoding', 'UTF-8'));
+var_dump(ini_set('output_encoding', 'UTF-8'));
+var_dump(ini_set('iconv.internal_encoding', 'UTF-8'));
+var_dump(ini_set('iconv.input_encoding', 'UTF-8'));
+var_dump(ini_set('iconv.output_encoding', 'UTF-8'));
+
+echo "Getting INI\n";
+var_dump(ini_get('default_charset'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('output_encoding'));
+
+var_dump(ini_get('iconv.internal_encoding'));
+var_dump(ini_get('iconv.input_encoding'));
+var_dump(ini_get('iconv.output_encoding'));
+
+--EXPECT--
+Getting INI
+string(10) "ISO-8859-1"
+string(0) ""
+string(0) ""
+string(0) ""
+string(10) "ISO-8859-1"
+string(0) ""
+string(0) ""
+Setting INI
+string(10) "ISO-8859-1"
+string(0) ""
+string(0) ""
+string(0) ""
+string(10) "ISO-8859-1"
+string(0) ""
+string(0) ""
+Getting INI
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
index 311a9f93f24f163a76087a5f8fd6031f9978cf15..e239c6c18bfe088a8f2ad5c5be0a4919ef10c4db 100644 (file)
@@ -183,17 +183,17 @@ string(3) "0.5"
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 11 --
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 12 --
 bool(true)
@@ -207,9 +207,9 @@ string(1) "1"
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 14 --
 bool(true)
@@ -223,25 +223,25 @@ string(1) "1"
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 16 --
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 17 --
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 18 --
 bool(true)
@@ -279,17 +279,17 @@ string(5) "UTF-8"
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 23 --
 bool(true)
 bool(true)
 bool(true)
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 
 -- Iteration 24 --
 
@@ -301,7 +301,7 @@ NULL
 
 Warning: iconv_set_encoding() expects parameter 2 to be string, resource given in %s on line %d
 NULL
-string(0) ""
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
 Done
\ No newline at end of file
index a3adbc357b9c0dea37a59a085016e35eb068ea98..1ae43602d15a0dcd066513f360479a57797f7570 100644 (file)
@@ -1236,6 +1236,11 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input)
                if (MBSTRG(http_input_list)) {
                        pefree(MBSTRG(http_input_list), 1);
                }
+               if (SUCCESS == php_mb_parse_encoding_list(PG(input_encoding), strlen(PG(input_encoding))+1, &list, &size, 1 TSRMLS_CC)) {
+                       MBSTRG(http_input_list) = list;
+                       MBSTRG(http_input_list_size) = 0;
+                       return SUCCESS;
+               }
                MBSTRG(http_input_list) = NULL;
                MBSTRG(http_input_list_size) = 0;
                return SUCCESS;
@@ -1261,18 +1266,20 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output)
        const mbfl_encoding *encoding;
 
        if (new_value == NULL || new_value_length == 0) {
-               MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
-               MBSTRG(current_http_output_encoding) = &mbfl_encoding_pass;
-               return SUCCESS;
-       }
-
-       encoding = mbfl_name2encoding(new_value);
-       if (!encoding) {
-               MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
-               MBSTRG(current_http_output_encoding) = &mbfl_encoding_pass;
-               return FAILURE;
+               encoding = mbfl_name2encoding(PG(output_encoding));
+               if (!encoding) {
+                       MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
+                       MBSTRG(current_http_output_encoding) = &mbfl_encoding_pass;
+                       return SUCCESS;
+               }
+       } else {
+               encoding = mbfl_name2encoding(new_value);
+               if (!encoding) {
+                       MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
+                       MBSTRG(current_http_output_encoding) = &mbfl_encoding_pass;
+                       return FAILURE;
+               }
        }
-
        MBSTRG(http_output_encoding) = encoding;
        MBSTRG(current_http_output_encoding) = encoding;
        return SUCCESS;
@@ -1285,47 +1292,17 @@ int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_v
        const mbfl_encoding *encoding;
 
        if (!new_value || new_value_length == 0 || !(encoding = mbfl_name2encoding(new_value))) {
-               switch (MBSTRG(language)) {
-                       case mbfl_no_language_uni:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_utf8);
-                               break;
-                       case mbfl_no_language_japanese:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_euc_jp);
-                               break;
-                       case mbfl_no_language_korean:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_euc_kr);
-                               break;
-                       case mbfl_no_language_simplified_chinese:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_euc_cn);
-                               break;
-                       case mbfl_no_language_traditional_chinese:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_euc_tw);
-                               break;
-                       case mbfl_no_language_russian:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_koi8r);
-                               break;
-                       case mbfl_no_language_german:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_8859_15);
-                               break;
-                       case mbfl_no_language_armenian:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_armscii8);
-                               break;
-                       case mbfl_no_language_turkish:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_8859_9);
-                               break;
-                       default:
-                               encoding = mbfl_no2encoding(mbfl_no_encoding_8859_1);
-                               break;
-               }
-       }
+               /* falls back to UTF-8 if an unkown encoding name is given */
+               encoding = mbfl_no2encoding(mbfl_no_encoding_utf8);
+       }
        MBSTRG(internal_encoding) = encoding;
        MBSTRG(current_internal_encoding) = encoding;
 #if HAVE_MBREGEX
        {
                const char *enc_name = new_value;
                if (FAILURE == php_mb_regex_set_default_mbctype(enc_name TSRMLS_CC)) {
-                       /* falls back to EUC-JP if an unknown encoding name is given */
-                       enc_name = "EUC-JP";
+                       /* falls back to UTF-8 if an unknown encoding name is given */
+                       enc_name = "UTF-8";
                        php_mb_regex_set_default_mbctype(enc_name TSRMLS_CC);
                }
                php_mb_regex_set_mbctype(new_value TSRMLS_CC);
@@ -1343,7 +1320,11 @@ static PHP_INI_MH(OnUpdate_mbstring_internal_encoding)
        }
        if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN
                        || stage == PHP_INI_STAGE_RUNTIME) {
-               return _php_mb_ini_mbstring_internal_encoding_set(new_value, new_value_length TSRMLS_CC);
+               if (new_value_length) {
+                       return _php_mb_ini_mbstring_internal_encoding_set(new_value, new_value_length TSRMLS_CC);
+               } else {
+                       return _php_mb_ini_mbstring_internal_encoding_set(PG(internal_encoding), strlen(PG(internal_encoding))+1 TSRMLS_CC);
+               }
        } else {
                /* the corresponding mbstring globals needs to be set according to the
                 * ini value in the later stage because it never falls back to the
@@ -1450,8 +1431,8 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes)
 PHP_INI_BEGIN()
        PHP_INI_ENTRY("mbstring.language", "neutral", PHP_INI_ALL, OnUpdate_mbstring_language)
        PHP_INI_ENTRY("mbstring.detect_order", NULL, PHP_INI_ALL, OnUpdate_mbstring_detect_order)
-       PHP_INI_ENTRY("mbstring.http_input", "pass", PHP_INI_ALL, OnUpdate_mbstring_http_input)
-       PHP_INI_ENTRY("mbstring.http_output", "pass", PHP_INI_ALL, OnUpdate_mbstring_http_output)
+       PHP_INI_ENTRY("mbstring.http_input", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_input)
+       PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output)
        STD_PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding, internal_encoding_name, zend_mbstring_globals, mbstring_globals)
        PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
        STD_PHP_INI_ENTRY("mbstring.func_overload", "0", 
@@ -2162,8 +2143,10 @@ PHP_FUNCTION(mb_output_handler)
  
        /* feed the string */
        mbfl_string_init(&string);
-       string.no_language = MBSTRG(language);
-       string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+       /* these are not needed. convd has encoding info.
+       string.no_language = MBSTRG(language);
+       string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+       */
        string.val = (unsigned char *)arg_string;
        string.len = arg_string_len;
        mbfl_buffer_converter_feed(MBSTRG(outconv), &string);
diff --git a/ext/mbstring/tests/ini_encoding.phpt b/ext/mbstring/tests/ini_encoding.phpt
new file mode 100644 (file)
index 0000000..79a0f3a
--- /dev/null
@@ -0,0 +1,73 @@
+--TEST--
+Encoding INI test
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--INI--
+default_charset=Shift_JIS
+internal_encoding=
+input_encoding=
+output_encoding=
+mbstring.internal_encoding=Shift_JIS
+mbstring.http_input=Shift_JIS
+mbstring.http_output=Shift_JIS
+--FILE--
+<?php
+echo "Getting INI\n";
+var_dump(ini_get('default_charset'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('output_encoding'));
+
+var_dump(ini_get('mbstring.internal_encoding'));
+var_dump(mb_internal_encoding());
+var_dump(ini_get('mbstring.http_input'));
+var_dump(ini_get('mbstring.http_output'));
+
+echo "Setting INI\n";
+var_dump(ini_set('default_charset', 'UTF-8'));
+var_dump(ini_set('internal_encoding', 'UTF-8'));
+var_dump(ini_set('input_encoding', 'UTF-8'));
+var_dump(ini_set('output_encoding', 'UTF-8'));
+var_dump(ini_set('mbstring.internal_encoding', 'UTF-8'));
+var_dump(ini_set('mbstring.http_input', 'UTF-8'));
+var_dump(ini_set('mbstring.http_output', 'UTF-8'));
+
+echo "Getting INI\n";
+var_dump(ini_get('default_charset'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('output_encoding'));
+
+var_dump(ini_get('mbstring.internal_encoding'));
+var_dump(mb_internal_encoding());
+var_dump(ini_get('mbstring.http_input'));
+var_dump(ini_get('mbstring.http_output'));
+
+
+--EXPECT--
+Getting INI
+string(9) "Shift_JIS"
+string(0) ""
+string(0) ""
+string(0) ""
+string(9) "Shift_JIS"
+string(4) "SJIS"
+string(9) "Shift_JIS"
+string(9) "Shift_JIS"
+Setting INI
+string(9) "Shift_JIS"
+string(0) ""
+string(0) ""
+string(0) ""
+string(9) "Shift_JIS"
+string(9) "Shift_JIS"
+string(9) "Shift_JIS"
+Getting INI
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
index 91fc050addb0e3d1469ca0ea036531372376f52f..075a4d2ff99d223d7b41d2f0a756486ba4242617 100644 (file)
@@ -1432,8 +1432,8 @@ encode_amp:
  */
 static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
 {
-       char *str, *hint_charset = NULL;
-       int str_len, hint_charset_len = 0;
+       char *str, *hint_charset = PHP_DEFAULT_CHARSET;
+       int str_len, hint_charset_len = sizeof(PHP_DEFAULT_CHARSET)-1;
        size_t new_len;
        long flags = ENT_COMPAT;
        char *replaced;
@@ -1504,8 +1504,8 @@ PHP_FUNCTION(htmlspecialchars_decode)
    Convert all HTML entities to their applicable characters */
 PHP_FUNCTION(html_entity_decode)
 {
-       char *str, *hint_charset = NULL;
-       int str_len, hint_charset_len = 0;
+       char *str, *hint_charset = PHP_DEFAULT_CHARSET;
+       int str_len, hint_charset_len = sizeof(PHP_DEFAULT_CHARSET)-1;
        size_t new_len = 0;
        long quote_style = ENT_COMPAT;
        char *replaced;
index a2158a95901d626256096556934e22837b3556f9..990ca6990c8f4d913d5e4c4d8464ce41a0fe65c1 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef SAPI_H
 #define SAPI_H
 
+#include "php.h"
 #include "zend.h"
 #include "zend_API.h"
 #include "zend_llist.h"
@@ -291,7 +292,7 @@ struct _sapi_post_entry {
 #define SAPI_HEADER_SEND_FAILED                        3
 
 #define SAPI_DEFAULT_MIMETYPE          "text/html"
-#define SAPI_DEFAULT_CHARSET           ""
+#define SAPI_DEFAULT_CHARSET           PHP_DEFAULT_CHARSET
 #define SAPI_PHP_VERSION_HEADER                "X-Powered-By: PHP/" PHP_VERSION
 
 #define SAPI_POST_READER_FUNC(post_reader) void post_reader(TSRMLS_D)
index 2d59c46930c26680a2f5a319d72de668037fffa0..abe032af70ec9d94dff79760e43859de5d32b2af 100644 (file)
@@ -415,6 +415,45 @@ static PHP_INI_DISP(display_errors_mode)
 }
 /* }}} */
 
+/* {{{ PHP_INI_MH
+ */
+static PHP_INI_MH(OnUpdateInternalEncoding)
+{
+       if (new_value_length) {
+               OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       } else {
+               OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       }
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_INI_MH
+ */
+static PHP_INI_MH(OnUpdateInputEncoding)
+{
+       if (new_value_length) {
+               OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       } else {
+               OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       }
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_INI_MH
+ */
+static PHP_INI_MH(OnUpdateOutputEncoding)
+{
+       if (new_value_length) {
+               OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       } else {
+               OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+       }
+       return SUCCESS;
+}
+/* }}} */
+
 /* {{{ PHP_INI_MH
  */
 static PHP_INI_MH(OnUpdateErrorLog)
@@ -556,8 +595,11 @@ PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("auto_append_file",           NULL,           PHP_INI_SYSTEM|PHP_INI_PERDIR,          OnUpdateString,                 auto_append_file,               php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("auto_prepend_file",          NULL,           PHP_INI_SYSTEM|PHP_INI_PERDIR,          OnUpdateString,                 auto_prepend_file,              php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("doc_root",                           NULL,           PHP_INI_SYSTEM,         OnUpdateStringUnempty,  doc_root,                               php_core_globals,       core_globals)
-       STD_PHP_INI_ENTRY("default_charset",            SAPI_DEFAULT_CHARSET,   PHP_INI_ALL,    OnUpdateString,                 default_charset,                sapi_globals_struct,sapi_globals)
-       STD_PHP_INI_ENTRY("default_mimetype",           SAPI_DEFAULT_MIMETYPE,  PHP_INI_ALL,    OnUpdateString,                 default_mimetype,               sapi_globals_struct,sapi_globals)
+       STD_PHP_INI_ENTRY("default_charset",            PHP_DEFAULT_CHARSET,    PHP_INI_ALL,    OnUpdateString,                 default_charset,                sapi_globals_struct, sapi_globals)
+       STD_PHP_INI_ENTRY("default_mimetype",           SAPI_DEFAULT_MIMETYPE,  PHP_INI_ALL,    OnUpdateString,                 default_mimetype,               sapi_globals_struct, sapi_globals)
+       STD_PHP_INI_ENTRY("internal_encoding",          "",                     PHP_INI_ALL,    OnUpdateInternalEncoding,       internal_encoding,      php_core_globals, core_globals)
+       STD_PHP_INI_ENTRY("input_encoding",                     "",                     PHP_INI_ALL,    OnUpdateInputEncoding,                          input_encoding,         php_core_globals, core_globals)
+       STD_PHP_INI_ENTRY("output_encoding",            "",                     PHP_INI_ALL,    OnUpdateOutputEncoding,                         output_encoding,        php_core_globals, core_globals)
        STD_PHP_INI_ENTRY("error_log",                          NULL,           PHP_INI_ALL,            OnUpdateErrorLog,                       error_log,                              php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("extension_dir",                      PHP_EXTENSION_DIR,              PHP_INI_SYSTEM,         OnUpdateStringUnempty,  extension_dir,                  php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("sys_temp_dir",                       NULL,           PHP_INI_SYSTEM,         OnUpdateStringUnempty,  sys_temp_dir,                   php_core_globals,       core_globals)
index 8f8ad33d87cc1c0aaa8e6685bd160b71b2a4b206..4330479d50113351d7230a5ee57c36832c55b356 100644 (file)
@@ -29,6 +29,7 @@
 #define PHP_API_VERSION 20131106
 #define PHP_HAVE_STREAMS
 #define YYDEBUG 0
+#define PHP_DEFAULT_CHARSET "UTF-8"
 
 #include "php_version.h"
 #include "zend.h"
index cf7998b83de23fdcf4fe3b7037d4f8e0d473a6f8..e135d61865c4d0a39fa32006a7dcaee59d6356ca 100644 (file)
@@ -96,6 +96,10 @@ struct _php_core_globals {
        char *auto_prepend_file;
        char *auto_append_file;
 
+       char *input_encoding;
+       char *internal_encoding;
+       char *output_encoding;
+
        arg_separators arg_separator;
 
        char *variables_order;
index 0ca81e8ffeca4547a58ee97cb88327f37a9cecf1..50fbba1fcf4c425d8d3e91cf1e69a06550961256 100644 (file)
@@ -678,9 +678,26 @@ auto_append_file =
 ; http://php.net/default-mimetype
 default_mimetype = "text/html"
 
-; PHP's default character set is set to empty.
+; PHP's default character set is set to UTF-8
 ; http://php.net/default-charset
-;default_charset = "UTF-8"
+default_charset = "UTF-8"
+
+; PHP internal character encoding is set to empty.
+; If empty, default_charset is used.
+; http://php.net/internal-encoding
+;internal_encoding =
+
+; PHP input character encoding is set to empty.
+; If empty, default_charset is used.
+; http://php.net/input-encoding
+;input_encoding =
+
+; PHP output character encoding is set to empty.
+; If empty, default_charset is used.
+; mbstring or iconv output handler is used.
+; See also output_buffer.
+; http://php.net/output-encoding
+;output_encoding =
 
 ; Always populate the $HTTP_RAW_POST_DATA variable. PHP's default behavior is
 ; to disable this feature and it will be removed in a future version.
@@ -932,9 +949,17 @@ cli_server.color = On
 ;filter.default_flags =
 
 [iconv]
-;iconv.input_encoding = ISO-8859-1
-;iconv.internal_encoding = ISO-8859-1
-;iconv.output_encoding = ISO-8859-1
+; Use of this INI entory is deprecated, use global input_encoding instead.
+; If empty, input_encoding is used.
+;iconv.input_encoding =
+
+; Use of this INI entory is deprecated, use global internal_encoding instead.
+; If empty, internal_encoding is used.
+;iconv.internal_encoding =
+
+; Use of this INI entory is deprecated, use global output_encoding instead.
+; If empty, output_encoding is used.
+;iconv.output_encoding =
 
 [intl]
 ;intl.default_locale =
@@ -1697,23 +1722,30 @@ mssql.secure_connection = Off
 
 [mbstring]
 ; language for internal character representation.
+; This affects mb_send_mail() and mbstrig.detect_order.
 ; http://php.net/mbstring.language
 ;mbstring.language = Japanese
 
+; Use of this INI entory is deprecated, use global internal_encoding instead.
 ; internal/script encoding.
-; Some encoding cannot work as internal encoding.
-; (e.g. SJIS, BIG5, ISO-2022-*)
+; Some encoding cannot work as internal encoding. (e.g. SJIS, BIG5, ISO-2022-*)
+; If empty, default_charset or internal_encoding is used in order.
 ; http://php.net/mbstring.internal-encoding
-;mbstring.internal_encoding = UTF-8
+;mbstring.internal_encoding =
 
+; Use of this INI entory is deprecated, use global input_encoding instead.
 ; http input encoding.
+; If empty, input_encoding is used.
+; mbstring.encoding_traslation = On is needed to use this setting.
 ; http://php.net/mbstring.http-input
-;mbstring.http_input = UTF-8
+;mbstring.http_input =
 
-; http output encoding. mb_output_handler must be
-; registered as output buffer to function
+; Use of this INI entory is deprecated, use global output_encoding instead.
+; http output encoding.
+; mb_output_handler must be registered as output buffer to function.
+; If empty, output_encoding is used.
 ; http://php.net/mbstring.http-output
-;mbstring.http_output = pass
+;mbstring.http_output =
 
 ; enable automatic encoding translation according to
 ; mbstring.internal_encoding setting. Input chars are
@@ -1724,7 +1756,7 @@ mssql.secure_connection = Off
 ;mbstring.encoding_translation = Off
 
 ; automatic encoding detection order.
-; auto means
+; "auto" detect order is changed accoding to mbstring.language
 ; http://php.net/mbstring.detect-order
 ;mbstring.detect_order = auto
 
@@ -1745,6 +1777,7 @@ mssql.secure_connection = Off
 ;mbstring.func_overload = 0
 
 ; enable strict encoding detection.
+; Default: Off
 ;mbstring.strict_detection = On
 
 ; This directive specifies the regex pattern of content types for which mb_output_handler()
index 3b6f5e3cf8c6f616fe5c49d48fe5240420371859..fcd96bfad9ca9409baa541eb811b9f32199ecb56 100644 (file)
@@ -680,7 +680,22 @@ default_mimetype = "text/html"
 
 ; PHP's default character set is set to empty.
 ; http://php.net/default-charset
-;default_charset = "UTF-8"
+default_charset = "UTF-8"
+
+; PHP internal character encoding is set to empty.
+; If empty, default_charset is used.
+; http://php.net/internal-encoding
+;internal_encoding =
+
+; PHP input character encoding is set to empty.
+; http://php.net/input-encoding
+;input_encoding =
+
+; PHP output character encoding is set to empty.
+; mbstring or iconv output handler is used.
+; See also output_buffer.
+; http://php.net/output-encoding
+;output_encoding =
 
 ; Always populate the $HTTP_RAW_POST_DATA variable. PHP's default behavior is
 ; to disable this feature and it will be removed in a future version.
@@ -932,9 +947,17 @@ cli_server.color = On
 ;filter.default_flags =
 
 [iconv]
-;iconv.input_encoding = ISO-8859-1
-;iconv.internal_encoding = ISO-8859-1
-;iconv.output_encoding = ISO-8859-1
+; Use of this INI entory is deprecated, use global input_encoding instead.
+; If empty, input_encoding is used.
+;iconv.input_encoding =
+
+; Use of this INI entory is deprecated, use global internal_encoding instead.
+; If empty, internal_encoding is used.
+;iconv.internal_encoding =
+
+; Use of this INI entory is deprecated, use global output_encoding instead.
+; If empty, output_encoding is used.
+;iconv.output_encoding =
 
 [intl]
 ;intl.default_locale =
@@ -1697,23 +1720,30 @@ mssql.secure_connection = Off
 
 [mbstring]
 ; language for internal character representation.
+; This affects mb_send_mail() and mbstrig.detect_order.
 ; http://php.net/mbstring.language
 ;mbstring.language = Japanese
 
+; Use of this INI entory is deprecated, use global internal_encoding instead.
 ; internal/script encoding.
-; Some encoding cannot work as internal encoding.
-; (e.g. SJIS, BIG5, ISO-2022-*)
+; Some encoding cannot work as internal encoding. (e.g. SJIS, BIG5, ISO-2022-*)
+; If empty, default_charset or internal_encoding is used in order.
 ; http://php.net/mbstring.internal-encoding
-;mbstring.internal_encoding = UTF-8
+;mbstring.internal_encoding =
 
+; Use of this INI entory is deprecated, use global input_encoding instead.
 ; http input encoding.
+; If empty, input_encoding is used.
+; mbstring.encoding_traslation = On is needed to use this setting.
 ; http://php.net/mbstring.http-input
-;mbstring.http_input = UTF-8
+;mbstring.http_input =
 
-; http output encoding. mb_output_handler must be
-; registered as output buffer to function
+; Use of this INI entory is deprecated, use global output_encoding instead.
+; http output encoding.
+; mb_output_handler must be registered as output buffer to function.
+; If empty, output_encoding is used.
 ; http://php.net/mbstring.http-output
-;mbstring.http_output = pass
+;mbstring.http_output =
 
 ; enable automatic encoding translation according to
 ; mbstring.internal_encoding setting. Input chars are
@@ -1724,7 +1754,7 @@ mssql.secure_connection = Off
 ;mbstring.encoding_translation = Off
 
 ; automatic encoding detection order.
-; auto means
+; "auto" detect order is changed accoding to mbstring.language
 ; http://php.net/mbstring.detect-order
 ;mbstring.detect_order = auto
 
@@ -1745,6 +1775,7 @@ mssql.secure_connection = Off
 ;mbstring.func_overload = 0
 
 ; enable strict encoding detection.
+; Default: Off
 ;mbstring.strict_detection = On
 
 ; This directive specifies the regex pattern of content types for which mb_output_handler()
index e633ad28baf5f894410c86a4ef5ad17c4b7a94fd..67e1a69e26e7930749f3d89c88a8b3eea23b8e93 100644 (file)
@@ -40,14 +40,14 @@ echo "Done\n";
 --EXPECTF--
 Status: 403 Forbidden
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 Status: 403 Forbidden
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 X-Powered-By: PHP/%s
 Status: 403 Also Forbidden
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 Done
index 177df021a67fc23cf865f6ca98cfd29e29d5c7ab..6d4a6ed7f90dfb493d937af86c8a6ca1f45a4996 100644 (file)
@@ -65,18 +65,18 @@ header_remove("X-Foo");
 <?php ?>
 ----------
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php header_remove(); ?>
 ----------
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php header_remove("X-Foo"); ?>
 ----------
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php
@@ -85,7 +85,7 @@ header("X-Foo: Bar");
 ----------
 X-Powered-By: PHP/%s
 X-Foo: Bar
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php
@@ -96,7 +96,7 @@ header_remove("X-Foo");
 ----------
 X-Powered-By: PHP/%s
 X-Bar: Baz
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php
@@ -106,7 +106,7 @@ header_remove("X-Foo: Bar");
 ----------
 X-Powered-By: PHP/%s
 X-Foo: Bar
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 
 Warning: Header to delete may not contain colon. in %s on line 3
@@ -118,7 +118,7 @@ header_remove("X-Foo:");
 ----------
 X-Powered-By: PHP/%s
 X-Foo: Bar
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 
 Warning: Header to delete may not contain colon. in %s on line 3
@@ -128,7 +128,7 @@ header("X-Foo: Bar");
 header_remove();
 ?>
 ----------
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php
@@ -136,7 +136,7 @@ header_remove("");
 ?>
 ----------
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 ----------
 <?php
@@ -144,7 +144,7 @@ header_remove(":");
 ?>
 ----------
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 
 Warning: Header to delete may not contain colon. in %s on line 2
@@ -158,7 +158,7 @@ header_remove("X-Foo");
 ----------
 X-Powered-By: PHP/%s
 X-Foo: Bar
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 flush
 
index 36b5504ab06849518527c73059379f3ffd717832..a97769cf8f16152c6095a04dcf1a20a3cd78a76d 100644 (file)
@@ -60,23 +60,23 @@ HTTP/1.1 200 OK
 Host: localhost
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 OK
 HTTP/1.0 500 Internal Server Error
 Host: localhost
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 HTTP/1.0 500 Internal Server Error
 Host: localhost
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 HTTP/1.0 500 Internal Server Error
 Host: localhost
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
index 3a97c7e910cea64d9f8f8566592358b439034644..901ba188fd2011e668485b0e2905d92153b2e8ae 100644 (file)
@@ -36,4 +36,4 @@ HTTP/1.1 100 Continue
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
index 2552d1d11d944f4bb179709d16b0cd94d836f327..4e5d31c7a7f5954d8882fdce94b03eb89bc00495 100644 (file)
@@ -36,4 +36,4 @@ HTTP/1.1 422 Unknown Status Code
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
index aa4a9a003068068a5a594459caba0b69a4ecb8fb..a0b4eae3931fb9e9811746b0e476a7f451d07976 100644 (file)
@@ -36,4 +36,4 @@ HTTP/1.1 511 Network Authentication Required
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
index 55834095b187796903a3b0e65c5245a783efa553..456436b1f794f5519aafdb21bb002702a9e5e559 100644 (file)
@@ -39,7 +39,7 @@ fclose($fp);
 HTTP/1.1 200 OK
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 array(1) {
   ["foo"]=>
index b61f88637e8db562f25e2cb82d4b4b1a8cb3734b..8b913f6596cba47d069ec2dff953bab36e214b45 100644 (file)
@@ -40,7 +40,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(19) "HTTP_HOST:localhost"
 string(21) "HTTP_USER_AGENT:dummy"
index ccc0f8f3ab05d0ea2e5cf573712c823e14b392e1..cdd0ae902fcaaf1fd6c90605bb9cfa8d23e95015 100644 (file)
@@ -52,7 +52,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 array(1) {
   ["userfile"]=>
index 09e7ab07a561a345e7c44190d7b5f7338961921c..ad6d6c9598b874335160a341043ecc50b8dd837b 100644 (file)
@@ -36,7 +36,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(3) "foo"
 string(3) "bar"
index 64d4df0ed70000d7443a6525404181fb92484d59..6420ff5a41208b7827d0ba71e4c4d854a4c43c64 100644 (file)
@@ -37,4 +37,4 @@ Host: %s
 Connection: close
 X-Powered-By: PHP/%s
 WWW-Authenticate: Digest realm="foo",qop="auth",nonce="XXXXX",opaque="acbd18db4cc2f85cedef654fccc4a4d8"
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
index 2e68e2405937b84b1396ca3ab4f16e56cca79cb1..01f825a74614d59590bc91a4765dbc225ffa1ba9 100644 (file)
@@ -56,13 +56,13 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(8) "HTTP/1.1"
 HTTP/1.0 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(8) "HTTP/1.0"
index 2beaeedab6be9fa6376111b13192552d0baddec5..231797160f249538e81d104af2d4bc6c2a47d897 100644 (file)
@@ -80,14 +80,14 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(8) "/foo/bar"
 HTTP/1.0 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(9) "/foo/bar/"
 HTTP/1.0 404 Not Found
index 2ef018b8579e6c2a522c9eaee6e6107f4804e7c7..30e6d047a71dd7f9a8a06a7bd1322089663257ce 100644 (file)
@@ -57,7 +57,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(18) "/index.php/foo/bar"
 string(10) "/index.php"
@@ -67,7 +67,7 @@ HTTP/1.0 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(19) "/index.php/foo/bar/"
 string(10) "/index.php"
index 9a1e60c48b13f5e71dc52add71803917a162190f..302540f7e67f4a020795b54a6bf6bb1b4e68a0d9 100644 (file)
@@ -42,7 +42,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 Array
 (
index 6fb016924401e0206b8ce6951dcd9df0cb1706d5..e3d8c4170db5ae6ae890b80a477397fb79048dd3 100644 (file)
@@ -43,7 +43,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 <br />
 <b>Fatal error</b>:  Call to undefined function non_exists_function() in <b>%ssyntax_error.php</b> on line <b>%s</b><br />
index 73530af480781d8c780e21615eb3e588237daddf..34e7d5e289ea0accd7b941020487661171cf9c19 100644 (file)
@@ -39,6 +39,6 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(%d) "%sindex.php"
index deb93487687a1493cff90966a74901361db919dc..44e12929349da54971d0bab99cad0ed2f9f60bed 100644 (file)
@@ -39,6 +39,6 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: %s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 string(5) "PATCH"
index 2b983e5c0aee3d0fc055336b616867cc892db03b..aeb7a9f89160954373995905ee6b7bf6c8b9bcc9 100644 (file)
@@ -44,7 +44,7 @@ Host: %s
 Connection: close
 X-Powered-By: %s
 Bar-Foo: Foo
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 array(2) {
   ["Host"]=>
@@ -64,5 +64,5 @@ array(3) {
   ["Bar-Foo"]=>
   string(3) "Foo"
   ["Content-type"]=>
-  string(9) "text/html"
+  string(24) "text/html; charset=UTF-8"
 }
index b8416ea730972a2ca325f90bfbcfa68ca163519f..707eddbad3e0d86a34c773a063e6b1b9ddd9087b 100644 (file)
@@ -43,7 +43,7 @@ if (!$fp) {
 }
 
 $prev = "----123
-Content-Type: text/plain
+Content-Type: text/plain; charset=UTF-8
 Content-Disposition: form-data; name=\"file1\"; filename=\"file1.txt\"\n\n";
 $post = "\n----123--\n";
 $total = $length + strlen($prev) + strlen($post);
@@ -79,7 +79,7 @@ HTTP/1.1 200 OK
 Host: %s
 Connection: close
 X-Powered-By: PHP/%s
-Content-type: text/html
+Content-type: text/html; charset=UTF-8
 
 array(1) {
   ["file1"]=>
diff --git a/tests/basic/encoding.phpt b/tests/basic/encoding.phpt
new file mode 100644 (file)
index 0000000..b2ee5f3
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+PHP encoding setting test
+--INI--
+--FILE--
+<?php
+var_dump(ini_get('default_charset'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('output_encoding'));
+
+var_dump(ini_set('default_charset', 'ISO-8859-1'));
+var_dump(ini_get('default_charset'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('output_encoding'));
+
+var_dump(ini_set('input_encoding', 'ISO-8859-1'));
+var_dump(ini_set('internal_encoding', 'ISO-8859-1'));
+var_dump(ini_set('output_encoding', 'ISO-8859-1'));
+var_dump(ini_get('input_encoding'));
+var_dump(ini_get('internal_encoding'));
+var_dump(ini_get('output_encoding'));
+
+--EXPECTF--
+string(5) "UTF-8"
+string(0) ""
+string(0) ""
+string(0) ""
+string(5) "UTF-8"
+string(10) "ISO-8859-1"
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
\ No newline at end of file