diff --git a/src/ChangeLog b/src/ChangeLog index e30990b0..ef69dca6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2008-06-19 Xavier Saint + + * iri.c, iri.h : Add a new function find_locale() to find + out the local system encoding. + + * main.c : Make use of find_locale(). + 2008-06-19 Xavier Saint * html-url.c : Add "content-type" meta tag parsing for diff --git a/src/iri.c b/src/iri.c index e4f4622b..797ffa44 100644 --- a/src/iri.c +++ b/src/iri.c @@ -68,3 +68,12 @@ parse_charset (char *str) } +/* Find the locale used, or fall back on a default value */ +char * +find_locale (void) +{ + /* sXXXav, made our own function or use libidn one ?! */ + return stringprep_locale_charset (); +} + + diff --git a/src/iri.h b/src/iri.h index 2ac7d5e7..eb344d9f 100644 --- a/src/iri.h +++ b/src/iri.h @@ -33,11 +33,12 @@ as that of the covered work. */ #ifdef ENABLE_IRI char *parse_charset (char *str); - +char *find_locale (void); #else /* ENABLE_IRI */ #define parse_charset(str) NULL +#define find_locale() NULL #endif /* ENABLE_IRI */ #endif /* IRI_H */ diff --git a/src/main.c b/src/main.c index 8002c1be..fc41153b 100644 --- a/src/main.c +++ b/src/main.c @@ -57,6 +57,7 @@ as that of the covered work. */ #include "convert.h" #include "spider.h" #include "http.h" /* for save_cookies */ +#include "iri.h" #include #include @@ -1067,17 +1068,11 @@ for details.\n\n")); if (opt.enable_iri) { if (!opt.locale) - { - opt.locale = getenv ("CHARSET"); + opt.locale = find_locale (); - if (opt.locale == NULL) - opt.locale = nl_langinfo(CODESET); - } - else - { - /* sXXXav : check given locale */ - logprintf (LOG_VERBOSE, "Check the locale...\n"); - } + /* sXXXav : check given locale and remote encoding */ + + logprintf (LOG_VERBOSE, "Locale = %s\n", quote (opt.locale)); } #else if (opt.enable_iri || opt.locale || opt.encoding_remote)