mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-28 08:14:24 +02:00
Update win32-utf8.c
Reflects mgkuhn's comment.
This commit is contained in:
parent
fb388657c8
commit
f01eb59dc4
@ -11,7 +11,7 @@
|
|||||||
UINT g_previous_codepage = 0;
|
UINT g_previous_codepage = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
mresetlocale(void);
|
mrestorelocale(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
vfmprintf(FILE *stream, const char *fmt, va_list ap)
|
vfmprintf(FILE *stream, const char *fmt, va_list ap)
|
||||||
@ -100,19 +100,22 @@ asmprintf(char **outp, size_t sz, int *written, const char *fmt, ...)
|
|||||||
void
|
void
|
||||||
msetlocale(void)
|
msetlocale(void)
|
||||||
{
|
{
|
||||||
// allow console output of unicode characters
|
// save previous codepage
|
||||||
g_previous_codepage = SetConsoleOutputCP(CP_UTF8);
|
g_previous_codepage = GetConsoleOutputCP();
|
||||||
|
|
||||||
// register reset function at exit
|
// allow console output of unicode characters
|
||||||
atexit(mresetlocale);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
|
||||||
|
// register a restore function at exit
|
||||||
|
atexit(mrestorelocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mresetlocale(void)
|
mrestorelocale(void)
|
||||||
{
|
{
|
||||||
if( 0 != g_previous_codepage )
|
if( 0 != g_previous_codepage )
|
||||||
{
|
{
|
||||||
// restore console output codepage for previous one
|
// restore console output codepage to previous one
|
||||||
SetConsoleOutputCP(g_previous_codepage);
|
SetConsoleOutputCP(g_previous_codepage);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user