diff --git a/util/ChangeLog b/util/ChangeLog index a8b87bd7a..4e0915ccc 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,8 @@ +2002-09-02 Werner Koch + + * strgutil.c (set_native_charset): Allow NULL as argument to use + nl_langinfo for selection. Mapped latin-15 to latin-1. + 2002-08-30 Werner Koch * iobuf.c (block_filter): Removed the assert, so that one can pass diff --git a/util/strgutil.c b/util/strgutil.c index ff1ff5126..858d603e0 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -22,6 +22,10 @@ #include #include #include +#ifdef HAVE_LANGINFO_CODESET +#include +#endif + #include "types.h" #include "util.h" #include "memory.h" @@ -361,12 +365,27 @@ string_count_chr( const char *string, int c ) int set_native_charset( const char *newset ) { - if( !ascii_strcasecmp( newset, "iso-8859-1" ) ) { - active_charset_name = "iso-8859-1"; + if (!newset) +#ifdef HAVE_LANGINFO_CODESET + newset = nl_langinfo (CODESET); +#else + newset = "8859-1"; +#endif + + if (strlen (newset) > 3 && !ascii_memcasecmp (newset, "iso", 3)) { + newset += 3; + if (*newset == '-' || *newset == '_') + newset++; + } + + if( !*newset + || !ascii_strcasecmp (newset, "8859-1" ) + || !ascii_strcasecmp (newset, "8859-15" ) ) { + active_charset_name = "iso-8859-1"; no_translation = 0; active_charset = NULL; } - else if( !ascii_strcasecmp( newset, "iso-8859-2" ) ) { + else if( !ascii_strcasecmp( newset, "8859-2" ) ) { active_charset_name = "iso-8859-2"; no_translation = 0; active_charset = latin2_unicode;