cvs: php4 /ext/standard html.c
| From: | Moriyoshi Koizumi | Date: | Tue, 22 Oct 2002 20:11:48 +0000 |
| Subject: | cvs: php4 /ext/standard html.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-15165@lists.php.net to get a copy of this message | ||
moriyoshi Tue Oct 22 16:11:48 2002 EDT
Modified files:
/php4/ext/standard html.c
Log:
Improved determine_charset() to use mbstring.internal_encoding when the last
param is a null string. (If the param is omitted, it takes iso-8859-1 as
the default charset in favour of backwards compatibility.)
Index: php4/ext/standard/html.c
diff -u php4/ext/standard/html.c:1.54 php4/ext/standard/html.c:1.55
--- php4/ext/standard/html.c:1.54 Thu Oct 3 08:06:52 2002
+++ php4/ext/standard/html.c Tue Oct 22 16:11:48 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.c,v 1.54 2002/10/03 12:06:52 andrey Exp $ */
+/* $Id: html.c,v 1.55 2002/10/22 20:11:48 moriyoshi Exp $ */
#include "php.h"
#include "reg.h"
@@ -31,6 +31,11 @@
#include <langinfo.h>
#endif
+#if HAVE_MBSTRING
+# include "ext/mbstring/mbstring.h"
+ZEND_EXTERN_MODULE_GLOBALS(mbstring)
+#endif
+
enum entity_charset { cs_terminator, cs_8859_1, cs_cp1252,
cs_8859_15, cs_utf_8, cs_big5, cs_gb2312,
cs_big5hkscs, cs_sjis, cs_eucjp};
@@ -525,6 +530,36 @@
return cs_8859_1;
if (strlen(charset_hint) == 0) {
+#if HAVE_MBSTRING
+ /* XXX: Ugly things. Why don't we look for a more sophisticated way? */
+ switch (MBSTRG(internal_encoding)) {
+ case mbfl_no_encoding_utf8:
+ return cs_utf_8;
+
+ case mbfl_no_encoding_euc_jp:
+ case mbfl_no_encoding_eucjp_win:
+ return cs_eucjp;
+
+ case mbfl_no_encoding_sjis:
+ case mbfl_no_encoding_sjis_win:
+ case mbfl_no_encoding_sjis_mac:
+ return cs_sjis;
+
+ case mbfl_no_encoding_cp1252:
+ return cs_cp1252;
+
+ case mbfl_no_encoding_8859_15:
+ return cs_8859_15;
+
+ case mbfl_no_encoding_big5:
+ return cs_big5;
+
+ case mbfl_no_encoding_euc_cn:
+ case mbfl_no_encoding_hz:
+ case mbfl_no_encoding_cp936:
+ return cs_gb2312;
+ }
+#endif
/* try to detect the charset for the locale */
#if HAVE_NL_LANGINFO && HAVE_LOCALE_H && defined(CODESET)
charset_hint = nl_langinfo(CODESET);