mirror of
https://github.com/git/git.git
synced 2026-02-01 13:31:58 +00:00
git-wrapper: don't set the console input code page
Using different code pages for console input (SetConsoleCP()) and console output (SetConsoleOutputCP()) doesn't make much sense and may be hazardous for native Windows programs. Git uses UTF-8 internally, so it actually needs 'SetConsoleCP(CP_UTF8)' rather than 'SetConsoleCP(GetACP())'. However, ReadFile() / ReadConsoleA() are broken with CP_UTF8 (and thus any higher level APIs such as fgetc(), getchar() etc.). Unicode-aware console input would have to be implemented via mingw_* wrappers using ReadConsoleW(). As Git typically launches an editor for anything more complex than ASCII-only, yes/no-style questions, this is currently not a problem. Drop 'SetConsoleCP()' from the git-wrapper, so that input and output code pages stay in sync. Signed-off-by: Karsten Blees <blees@dcon.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
19f9a36d9c
commit
55abcbac7b
@@ -321,7 +321,6 @@ int main(void)
|
||||
WCHAR exepath[MAX_PATH], exe[MAX_PATH];
|
||||
LPWSTR cmd = NULL, exep = exe, prefix_args = NULL, basename;
|
||||
LPWSTR working_directory = NULL;
|
||||
UINT codepage = 0;
|
||||
|
||||
/* Determine MSys2-based Git path. */
|
||||
swprintf(msystem_bin, sizeof(msystem_bin),
|
||||
@@ -437,10 +436,6 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* set the console to ANSI/GUI codepage */
|
||||
codepage = GetConsoleCP();
|
||||
SetConsoleCP(GetACP());
|
||||
|
||||
{
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
@@ -499,7 +494,5 @@ int main(void)
|
||||
|
||||
free(cmd);
|
||||
|
||||
/* reset the console codepage */
|
||||
SetConsoleCP(codepage);
|
||||
ExitProcess(r);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user