mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
w32: Add fallback in case the Windows console can't cope with Unicode.
* common/ttyio.c (w32_write_console): Fallback to WriteConsoleA on error. -- To test this switch the Windows Console to "legacy mode" set LANG=de gpg --card-edit and enter an invalid command. The response contains an Umlaut and old Windows versions (and the legacy console) don't have a proper font installed for this. Without this patch this runs into a log_fatal error. The mitigation we implement is to fallback to WriteConsoleA, that is accepting wrong encoding and to print a note about the problem. GnuPG-bug-id: 5491
This commit is contained in:
parent
e387cc97c8
commit
edfe9453be
@ -236,10 +236,24 @@ w32_write_console (const char *string)
|
|||||||
n = wcslen (wstring);
|
n = wcslen (wstring);
|
||||||
|
|
||||||
if (!WriteConsoleW (con.out, wstring, n, &nwritten, NULL))
|
if (!WriteConsoleW (con.out, wstring, n, &nwritten, NULL))
|
||||||
log_fatal ("WriteConsole failed: %s", w32_strerror (-1));
|
{
|
||||||
if (n != nwritten)
|
static int shown;
|
||||||
log_fatal ("WriteConsole failed: %lu != %lu\n",
|
if (!shown)
|
||||||
(unsigned long)n, (unsigned long)nwritten);
|
{
|
||||||
|
shown = 1;
|
||||||
|
log_info ("WriteConsole failed: %s", w32_strerror (-1));
|
||||||
|
log_info ("Please configure a suitable font for the console\n");
|
||||||
|
}
|
||||||
|
n = strlen (string);
|
||||||
|
if (!WriteConsoleA (con.out, string, n , &nwritten, NULL))
|
||||||
|
log_fatal ("WriteConsole fallback failed: %s", w32_strerror (-1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (n != nwritten)
|
||||||
|
log_fatal ("WriteConsole failed: %lu != %lu\n",
|
||||||
|
(unsigned long)n, (unsigned long)nwritten);
|
||||||
|
}
|
||||||
last_prompt_len += n;
|
last_prompt_len += n;
|
||||||
xfree (wstring);
|
xfree (wstring);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user