summaryrefslogtreecommitdiff
path: root/ext/standard/html.c
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2002-10-24 22:04:28 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2002-10-24 22:04:28 +0000
commitd347143fe1ca87823920d1b395448290353ce07f (patch)
tree7fb9edfea128ac0c57d35857050ef62b45d89349 /ext/standard/html.c
parentc7c418c25a98e0360da3da916574603455c384d9 (diff)
downloadphp-git-d347143fe1ca87823920d1b395448290353ce07f.tar.gz
Improved determine_charset() to look up SG(default_charset) value
Diffstat (limited to 'ext/standard/html.c')
-rw-r--r--ext/standard/html.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/ext/standard/html.c b/ext/standard/html.c
index 04af990cd1..0fa8c4f0e1 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -24,6 +24,7 @@
#include "reg.h"
#include "html.h"
#include "php_string.h"
+#include "SAPI.h"
#if HAVE_LOCALE_H
#include <locale.h>
#endif
@@ -529,7 +530,7 @@ static enum entity_charset determine_charset(char *charset_hint TSRMLS_DC)
if (charset_hint == NULL)
return cs_8859_1;
- if (strlen(charset_hint) == 0) {
+ if ((len = strlen(charset_hint)) == 0) {
#if HAVE_MBSTRING
/* XXX: Ugly things. Why don't we look for a more sophisticated way? */
switch (MBSTRG(internal_encoding)) {
@@ -563,46 +564,45 @@ static enum entity_charset determine_charset(char *charset_hint TSRMLS_DC)
return cs_gb2312;
}
#endif
- /* try to detect the charset for the locale */
+ charset_hint = SG(default_charset);
+ if (charset_hint == NULL || (len=strlen(charset_hint)) == 0) {
+ /* try to detect the charset for the locale */
#if HAVE_NL_LANGINFO && HAVE_LOCALE_H && defined(CODESET)
- charset_hint = nl_langinfo(CODESET);
+ charset_hint = nl_langinfo(CODESET);
#endif
#if HAVE_LOCALE_H
- if (charset_hint == NULL) {
- /* try to figure out the charset from the locale */
- char *localename;
- char *dot, *at;
-
- /* lang[_territory][.codeset][@modifier] */
- localename = setlocale(LC_CTYPE, NULL);
-
- dot = strchr(localename, '.');
- if (dot) {
- dot++;
- /* locale specifies a codeset */
- at = strchr(dot, '@');
- if (at)
- len = at - dot;
- else
- len = strlen(dot);
- charset_hint = dot;
+ if (charset_hint == NULL) {
+ /* try to figure out the charset from the locale */
+ char *localename;
+ char *dot, *at;
+
+ /* lang[_territory][.codeset][@modifier] */
+ localename = setlocale(LC_CTYPE, NULL);
+
+ dot = strchr(localename, '.');
+ if (dot) {
+ dot++;
+ /* locale specifies a codeset */
+ at = strchr(dot, '@');
+ if (at)
+ len = at - dot;
+ else
+ len = strlen(dot);
+ charset_hint = dot;
+ } else {
+ /* no explicit name; see if the name itself
+ * is the charset */
+ charset_hint = localename;
+ len = strlen(charset_hint);
+ }
} else {
- /* no explicit name; see if the name itself
- * is the charset */
- charset_hint = localename;
len = strlen(charset_hint);
}
- } else
- len = strlen(charset_hint);
-#else
- if (charset_hint)
- len = strlen(charset_hint);
#endif
+ }
}
if (charset_hint) {
int found = 0;
- if (!len)
- len = strlen(charset_hint);
/* now walk the charset map and look for the codeset */
for (i = 0; charset_map[i].codeset; i++) {