diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/winansi.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index de6db08e2..dbdba9626 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -29,6 +29,10 @@ | |||
29 | static WORD plain_attr = 0xffff; | 29 | static WORD plain_attr = 0xffff; |
30 | static WORD current_attr; | 30 | static WORD current_attr; |
31 | 31 | ||
32 | #if ENABLE_FEATURE_EURO | ||
33 | static void init_codepage(void); | ||
34 | #endif | ||
35 | |||
32 | static HANDLE get_console(void) | 36 | static HANDLE get_console(void) |
33 | { | 37 | { |
34 | return GetStdHandle(STD_OUTPUT_HANDLE); | 38 | return GetStdHandle(STD_OUTPUT_HANDLE); |
@@ -75,6 +79,11 @@ int terminal_mode(int reset) | |||
75 | { | 79 | { |
76 | static int mode = -1; | 80 | static int mode = -1; |
77 | 81 | ||
82 | #if ENABLE_FEATURE_EURO | ||
83 | if (mode < 0) | ||
84 | init_codepage(); | ||
85 | #endif | ||
86 | |||
78 | if (mode < 0 || reset) { | 87 | if (mode < 0 || reset) { |
79 | HANDLE h; | 88 | HANDLE h; |
80 | DWORD oldmode, newmode; | 89 | DWORD oldmode, newmode; |
@@ -699,7 +708,7 @@ static char *process_escape(char *pos) | |||
699 | } | 708 | } |
700 | 709 | ||
701 | #if ENABLE_FEATURE_EURO | 710 | #if ENABLE_FEATURE_EURO |
702 | void init_codepage(void) | 711 | static void init_codepage(void) |
703 | { | 712 | { |
704 | if (GetConsoleCP() == 850 && GetConsoleOutputCP() == 850) { | 713 | if (GetConsoleCP() == 850 && GetConsoleOutputCP() == 850) { |
705 | SetConsoleCP(858); | 714 | SetConsoleCP(858); |
@@ -715,6 +724,7 @@ static BOOL winansi_CharToOemBuff(LPCSTR s, LPSTR d, DWORD len) | |||
715 | if (!s || !d) | 724 | if (!s || !d) |
716 | return FALSE; | 725 | return FALSE; |
717 | 726 | ||
727 | terminal_mode(FALSE); | ||
718 | buf = xmalloc(len*sizeof(WCHAR)); | 728 | buf = xmalloc(len*sizeof(WCHAR)); |
719 | MultiByteToWideChar(CP_ACP, 0, s, len, buf, len); | 729 | MultiByteToWideChar(CP_ACP, 0, s, len, buf, len); |
720 | WideCharToMultiByte(CP_OEMCP, 0, buf, len, d, len, NULL, NULL); | 730 | WideCharToMultiByte(CP_OEMCP, 0, buf, len, d, len, NULL, NULL); |
@@ -744,6 +754,7 @@ static BOOL winansi_OemToCharBuff(LPCSTR s, LPSTR d, DWORD len) | |||
744 | if (!s || !d) | 754 | if (!s || !d) |
745 | return FALSE; | 755 | return FALSE; |
746 | 756 | ||
757 | terminal_mode(FALSE); | ||
747 | buf = xmalloc(len*sizeof(WCHAR)); | 758 | buf = xmalloc(len*sizeof(WCHAR)); |
748 | MultiByteToWideChar(CP_OEMCP, 0, s, len, buf, len); | 759 | MultiByteToWideChar(CP_OEMCP, 0, s, len, buf, len); |
749 | WideCharToMultiByte(CP_ACP, 0, buf, len, d, len, NULL, NULL); | 760 | WideCharToMultiByte(CP_ACP, 0, buf, len, d, len, NULL, NULL); |