diff options
author | Werner Koch <wk@gnupg.org> | 2002-09-02 12:58:30 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2002-09-02 12:58:30 +0200 |
commit | f3484f7844fa89df9b22164b6c14ed88029aa381 (patch) | |
tree | 4245a6f52a7cdc5622127597f241a41b09e5af4c | |
parent | * gnupg.7: New mini man page. (diff) | |
download | gnupg2-f3484f7844fa89df9b22164b6c14ed88029aa381.tar.xz gnupg2-f3484f7844fa89df9b22164b6c14ed88029aa381.zip |
* strgutil.c (set_native_charset): Allow NULL as argument to use
nl_langinfo for selection. Mapped latin-15 to latin-1.
-rw-r--r-- | util/ChangeLog | 5 | ||||
-rw-r--r-- | util/strgutil.c | 25 |
2 files changed, 27 insertions, 3 deletions
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 <wk@gnupg.org> + + * 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 <wk@gnupg.org> * 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 <stdlib.h> #include <string.h> #include <ctype.h> +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#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; |