#include #include #include int main(void) { DWORD dummy; BOOL ret; WCHAR str_uni[]={0x044d, 0x0442, 0x043e, 0x0020, 0x0442, 0x0435, 0x0441, 0x0442, '\r', '\n', 0x0000}; char str_cp866[]="��� ������� ����� in cp866\n\0\0"; char str_cp1251[]="��� ������� ����� in cp1251\n\0\0"; char *loc_str; loc_str = setlocale(LC_ALL, NULL); printf("current locale %s\n", loc_str); loc_str = setlocale(LC_ALL, "Russian"); printf("current locale %s\n", loc_str); SetConsoleOutputCP(866); printf("WriteConsoleW: "); SetLastError(-1); ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str_uni, lstrlenW(str_uni), &dummy, NULL); if (!ret) printf("error %d\n", GetLastError()); printf("WriteConsoleA: "); SetLastError(-1); ret = WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), str_cp866, lstrlenA(str_cp866), &dummy, NULL); if (!ret) printf("error %d\n", GetLastError()); printf("wprintf(%%ws): "); wprintf(L"%ws", L"unicode string �������\n"); printf("printf: "); printf("%s", str_cp866); printf("printf: "); printf("%s", str_cp1251); SetConsoleOutputCP(1251); printf("WriteConsoleW: "); SetLastError(-1); ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str_uni, lstrlenW(str_uni), &dummy, NULL); if (!ret) printf("error %d\n", GetLastError()); printf("WriteConsoleA: "); SetLastError(-1); ret = WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), str_cp1251, lstrlenA(str_cp1251), &dummy, NULL); if (!ret) printf("error %d\n", GetLastError()); printf("wprintf(%%ws): "); wprintf(L"%ws", L"unicode string �������\n"); printf("printf: "); printf("%s", str_cp866); printf("printf: "); printf("%s", str_cp1251); return 0; }