[git] GPG-ERROR - branch, master, updated. libgpg-error-1.20-12-g823e858

by Andre Heinecke cvs at cvs.gnupg.org
Fri Dec 11 13:05:57 CET 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Error codes used by GnuPG et al.".

The branch, master has been updated
       via  823e858cdf5eb6b9945a46478f9876819c16bcd3 (commit)
      from  68827cbba2083db40df92de1bc449a3d2d0e81ed (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 823e858cdf5eb6b9945a46478f9876819c16bcd3
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Nov 30 16:09:40 2015 +0100

    Fix windows 8bit encoding conversion
    
    * src/w32-gettext.c (wchar_to_native): Convert to ConsoleOutputCP.
    
    --
    Just using CP_ACP did not neccessarily convert to the correct
    codepage as codepages might differ between ConsoleOutput and
    GUI output (which it usually does).
    This fixes encoding issues on the Windows commandline.

diff --git a/src/w32-gettext.c b/src/w32-gettext.c
index 2eb0289..146de53 100644
--- a/src/w32-gettext.c
+++ b/src/w32-gettext.c
@@ -1373,17 +1373,25 @@ utf8_to_wchar (const char *string, size_t length, size_t *retlen)
 }
 
 
-/* Return a malloced string encoded in UTF-8 from the wide char input
-   string STRING.  Caller must free this value. On failure returns
-   NULL.  The result of calling this function with STRING set to NULL
+/* Return a malloced string encoded in the native console codepage
+   from the wide char input string STRING.
+   Caller must free this value. On failure returns NULL.
+   The result of calling this function with STRING set to NULL
    is not defined. */
 static char *
 wchar_to_native (const wchar_t *string, size_t length, size_t *retlen)
 {
   int n;
   char *result;
+  unsigned int cpno = GetConsoleOutputCP ();
+
+  /* GetConsoleOutputCP returns the 8-Bit codepage that should be used
+     for console output. If the codepage is not returned we fall back
+     to the codepage GUI programs should use (CP_ACP). */
+  if (!cpno)
+    cpno = GetACP ();
 
-  n = WideCharToMultiByte (CP_ACP, 0, string, length, NULL, 0, NULL, NULL);
+  n = WideCharToMultiByte (cpno, 0, string, length, NULL, 0, NULL, NULL);
   if (n < 0 || (n+1) <= 0)
     return NULL;
 
@@ -1391,7 +1399,7 @@ wchar_to_native (const wchar_t *string, size_t length, size_t *retlen)
   if (!result)
     return NULL;
 
-  n = WideCharToMultiByte (CP_ACP, 0, string, length, result, n, NULL, NULL);
+  n = WideCharToMultiByte (cpno, 0, string, length, result, n, NULL, NULL);
   if (n < 0)
     {
       jnlib_free (result);

-----------------------------------------------------------------------

Summary of changes:
 src/w32-gettext.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
Error codes used by GnuPG et al.
http://git.gnupg.org




More information about the Gnupg-commits mailing list