diff options
author | Werner Koch <[email protected]> | 2004-10-27 16:32:51 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2004-10-27 16:32:51 +0000 |
commit | e216c20f40d51bf3504c36e7311a03bf467fe725 (patch) | |
tree | 316bd9dcb20bf88ddb70fa3af47f0ac02c58d5be /util/strgutil.c | |
parent | (load_libiconv) [_WIN32]: new. (diff) | |
download | gnupg-e216c20f40d51bf3504c36e7311a03bf467fe725.tar.gz gnupg-e216c20f40d51bf3504c36e7311a03bf467fe725.zip |
* dynload.h: Always use it for _WIN32.
* LINGUAS: Better don't have comments in this file.
* mk-w32-dist: Use utf-8 encoding for all MO files.
* simple-gettext.c: Removed windows.h.
(get_string): On the fly translation from utf-8 to active
character set.
* strgutil.c (load_libiconv) [_WIN32]: new.
(set_native_charset) [_WIN32]: Call it here and autodetect the
used code page.
(native_to_utf8, utf8_to_native): Reverted arguments for
iconv_open.
(handle_iconv_error): Made this function match iconv_open argumnet
ordering.
(utf8_to_native): Disable all quoting for DELIM == -1.
Diffstat (limited to 'util/strgutil.c')
-rw-r--r-- | util/strgutil.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/util/strgutil.c b/util/strgutil.c index 5b1182e0d..67dafcee5 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -480,10 +480,17 @@ set_native_charset( const char *newset ) #ifdef _WIN32 static char codepage[30]; - sprintf (codepage, "CP%u", (unsigned int)GetACP ()); - - /* If it is the Windows name for Latin-1 we use the - * standard name instead to avoid loading of iconv.dll. */ + /* We are a console program thus we need to use the + GetConsoleOutputCP fucntion and not the the GetACP which + would give the codepage for a GUI program. Note this is + not a bulletproof detection because GetConsoleCP might + retrun a different one for console input. Not sure how to + cope with that. */ + sprintf (codepage, "CP%u", (unsigned int)GetConsoleOutputCP ()); + /* If it is the Windows name for Latin-1 we use the standard + name instead to avoid loading of iconv.dll. Unfortunately + it is often CP850 and we don't have a custom translation + for it. */ if (!strcmp (codepage, "CP1252")) newset = "iso-8859-1"; else @@ -688,8 +695,9 @@ native_to_utf8( const char *string ) * Convert string, which is in UTF8 to native encoding. illegal * encodings by some "\xnn" and quote all control characters. A * character with value DELIM will always be quoted, it must be a - * vanilla ASCII character. - */ + * vanilla ASCII character. A DELIM value of -1 is special: it disables + * all quoting of control characters. + */ char * utf8_to_native( const char *string, size_t length, int delim ) { @@ -722,8 +730,9 @@ utf8_to_native( const char *string, size_t length, int delim ) } if( !nleft ) { if( !(*s & 0x80) ) { /* plain ascii */ - if( *s < 0x20 || *s == 0x7f || *s == delim || - (delim && *s=='\\')) { + if( delim != -1 + && (*s < 0x20 || *s == 0x7f || *s == delim + || (delim && *s=='\\'))) { n++; if( p ) *p++ = '\\'; |