"Kirill K. Smirnov" lich@math.spbu.ru wrote:
@@ -141,12 +138,19 @@ HWND WINAPI GetConsoleWindow(VOID) */ UINT WINAPI GetConsoleCP(VOID) {
- if (!console_input_codepage)
- BOOL ret;
- UINT codepage = GetOEMCP(); /* default value */
- SERVER_START_REQ(get_console_input_info) {
console_input_codepage = GetOEMCP();
- TRACE("%u\n", console_input_codepage);
req->handle = 0;
ret = !wine_server_call_err( req );
if (ret && reply->codepage)
codepage = reply->codepage;
Did you test what happens when an app sets console code page to a pseudo cp like CP_ACP (0)? Your code will force code page to be always equal to what GetOEMCP returns in that case.
IsValidCodePage will fail. App is not allowed to pass CP_ACP, CP_OEMCP and other pseudo codepages to these function.
#include <windows.h>
int main(void) { printf("%d\n", IsValidCodePage(CP_ACP)); printf("%d\n", IsValidCodePage(CP_OEMCP));
SetConsoleCP(CP_ACP); printf("%d\n", GetConsoleCP()); SetConsoleOutputCP(CP_ACP); printf("%d\n", GetConsoleOutputCP());
SetConsoleCP(CP_OEMCP); printf("%d\n", GetConsoleCP()); SetConsoleOutputCP(CP_OEMCP); printf("%d\n", GetConsoleOutputCP()); return 0; }
Small test: This will write under both wine and windows: 0 0 866 866 866 866
If change codepage to cp1251 via chcp, output will be: 0 0 1251 1251 1251 1251
So my code is OK. -- Kirill