mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-10 21:38:50 +01:00
(set_native_charset): Assume that ASCII,
ANSI_X3.4-1968 and 646 are actually meant as Latin-1. If nl_langinfo is not available get the charset from environment variables. For W32 use GetACP as error fallback. Removed Latin-15 to Latin-1 aliasing.
This commit is contained in:
parent
299a250c94
commit
9dc1bcc4ea
@ -1,3 +1,11 @@
|
|||||||
|
2005-01-06 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* strgutil.c (set_native_charset): Assume that ASCII,
|
||||||
|
ANSI_X3.4-1968 and 646 are actually meant as Latin-1. If
|
||||||
|
nl_langinfo is not available get the charset from environment
|
||||||
|
variables. For W32 use GetACP as error fallback. Removed Latin-15
|
||||||
|
to Latin-1 aliasing.
|
||||||
|
|
||||||
2004-12-28 David Shaw <dshaw@jabberwocky.com>
|
2004-12-28 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* srv.h: Better implementation for the SRV check. We don't need
|
* srv.h: Better implementation for the SRV check. We don't need
|
||||||
|
@ -144,6 +144,8 @@ load_libiconv (void)
|
|||||||
{
|
{
|
||||||
log_info (_("error loading `%s': %s\n"),
|
log_info (_("error loading `%s': %s\n"),
|
||||||
"iconv.dll", dlerror ());
|
"iconv.dll", dlerror ());
|
||||||
|
log_info(_("please see http://www.gnupg.org/download/iconv.html "
|
||||||
|
"for more information\n"));
|
||||||
iconv_open = NULL;
|
iconv_open = NULL;
|
||||||
iconv = NULL;
|
iconv = NULL;
|
||||||
iconv_close = NULL;
|
iconv_close = NULL;
|
||||||
@ -479,14 +481,19 @@ set_native_charset( const char *newset )
|
|||||||
if (!newset) {
|
if (!newset) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static char codepage[30];
|
static char codepage[30];
|
||||||
|
unsigned int cpno;
|
||||||
|
|
||||||
/* We are a console program thus we need to use the
|
/* We are a console program thus we need to use the
|
||||||
GetConsoleOutputCP fucntion and not the the GetACP which
|
GetConsoleOutputCP function and not the the GetACP which
|
||||||
would give the codepage for a GUI program. Note this is
|
would give the codepage for a GUI program. Note this is
|
||||||
not a bulletproof detection because GetConsoleCP might
|
not a bulletproof detection because GetConsoleCP might
|
||||||
retrun a different one for console input. Not sure how to
|
return a different one for console input. Not sure how to
|
||||||
cope with that. */
|
cope with that. If the console Code page is not known we
|
||||||
sprintf (codepage, "CP%u", (unsigned int)GetConsoleOutputCP ());
|
fall back to the system code page. */
|
||||||
|
cpno = GetConsoleOutputCP ();
|
||||||
|
if (!cpno)
|
||||||
|
cpno = GetACP ();
|
||||||
|
sprintf (codepage, "CP%u", cpno );
|
||||||
/* If it is the Windows name for Latin-1 we use the standard
|
/* If it is the Windows name for Latin-1 we use the standard
|
||||||
name instead to avoid loading of iconv.dll. Unfortunately
|
name instead to avoid loading of iconv.dll. Unfortunately
|
||||||
it is often CP850 and we don't have a custom translation
|
it is often CP850 and we don't have a custom translation
|
||||||
@ -498,9 +505,32 @@ set_native_charset( const char *newset )
|
|||||||
#else
|
#else
|
||||||
#ifdef HAVE_LANGINFO_CODESET
|
#ifdef HAVE_LANGINFO_CODESET
|
||||||
newset = nl_langinfo (CODESET);
|
newset = nl_langinfo (CODESET);
|
||||||
#else
|
#else /* !HAVE_LANGINFO_CODESET */
|
||||||
newset = "iso-8859-1";
|
/* Try to get the used charset from environment variables. */
|
||||||
#endif
|
static char codepage[30];
|
||||||
|
const char *lc, *dot, *mod;
|
||||||
|
|
||||||
|
strcpy (codepage, "iso-8859-1");
|
||||||
|
lc = getenv ("LC_ALL");
|
||||||
|
if (!lc || !*lc) {
|
||||||
|
lc = getenv ("LC_CTYPE");
|
||||||
|
if (!lc || !*lc)
|
||||||
|
lc = getenv ("LANG");
|
||||||
|
}
|
||||||
|
if (lc && *lc) {
|
||||||
|
dot = strchr (lc, '.');
|
||||||
|
if (dot) {
|
||||||
|
mod = strchr (++dot, '@');
|
||||||
|
if (!mod)
|
||||||
|
mod = dot + strlen (dot);
|
||||||
|
if (mod - dot < sizeof codepage && dot != mod) {
|
||||||
|
memcpy (codepage, dot, mod - dot);
|
||||||
|
codepage [mod - dot] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newset = codepage;
|
||||||
|
#endif /* !HAVE_LANGINFO_CODESET */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,9 +541,18 @@ set_native_charset( const char *newset )
|
|||||||
newset++;
|
newset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Note that we silently assume that plain ASCII is actually meant
|
||||||
|
as Latin-1. This makes sense because many Unix system don't
|
||||||
|
have their locale set up properly and thus would get annoying
|
||||||
|
error messages and we have to handle all the "bug"
|
||||||
|
reports. Latin-1 has always been the character set used for 8
|
||||||
|
bit characters on Unix systems. */
|
||||||
if( !*newset
|
if( !*newset
|
||||||
|| !ascii_strcasecmp (newset, "8859-1" )
|
|| !ascii_strcasecmp (newset, "8859-1" )
|
||||||
|| !ascii_strcasecmp (newset, "8859-15" ) ) {
|
|| !ascii_strcasecmp (newset, "646" )
|
||||||
|
|| !ascii_strcasecmp (newset, "ASCII" )
|
||||||
|
|| !ascii_strcasecmp (newset, "ANSI_X3.4-1968" )
|
||||||
|
) {
|
||||||
active_charset_name = "iso-8859-1";
|
active_charset_name = "iso-8859-1";
|
||||||
no_translation = 0;
|
no_translation = 0;
|
||||||
active_charset = NULL;
|
active_charset = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user