mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-30 01:05:14 +02:00
Merge pull request #666 from kemaruya/latestw_all
It is a workaround to address the #2027 issue.
This commit is contained in:
commit
29ad502773
@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
|
// previous codepage
|
||||||
|
UINT g_previous_codepage = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
mrestorelocale(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
vfmprintf(FILE *stream, const char *fmt, va_list ap)
|
vfmprintf(FILE *stream, const char *fmt, va_list ap)
|
||||||
@ -95,7 +100,22 @@ asmprintf(char **outp, size_t sz, int *written, const char *fmt, ...)
|
|||||||
void
|
void
|
||||||
msetlocale(void)
|
msetlocale(void)
|
||||||
{
|
{
|
||||||
|
// save previous codepage
|
||||||
|
g_previous_codepage = GetConsoleOutputCP();
|
||||||
|
|
||||||
// allow console output of unicode characters
|
// allow console output of unicode characters
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
|
||||||
|
// register a restore function at exit
|
||||||
|
atexit(mrestorelocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mrestorelocale(void)
|
||||||
|
{
|
||||||
|
if( 0 != g_previous_codepage )
|
||||||
|
{
|
||||||
|
// restore console output codepage to previous one
|
||||||
|
SetConsoleOutputCP(g_previous_codepage);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user