Due to server problems the website is temporarily offline! Visit http://www.smorgasbordet.com/pellesc/ to download Pelles C.
#include <stdio.h>#include <wchar.h>#include <windows.h>int main(void){ wchar_t *a = L"中文"; DWORD n; SetFileApisToOEM(); SetConsoleOutputCP(936); WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), a, wcslen(a), &n, NULL); wprintf(L"%ls\n", a); wprintf(L"%ls\n", L"中文"); return 0;}
中文-?-?Press any key to continue...
char MbStr[32]; WideCharToMultiByte(936, WC_DEFAULTCHAR, L"中文", -1, MbStr, 32, NULL, NULL); printf("%s\n",MbStr);
#include <stdio.h>#include <wchar.h>#include <windows.h>int main(void){ char MbStr[32]; WideCharToMultiByte(936, WC_DEFAULTCHAR, L"中文", -1, MbStr, 32, NULL, NULL); printf("%s\n", MbStr); return 0;}
)Press any key to continue...
Have you created this as a windows project or a console project?
Add '-subsystem:windows' on linker command line or select subsystem=windows form linker tab.
Code: [Select]#include <stdio.h>#include <wchar.h>#include <windows.h>int main(void){ char MbStr[32]; WideCharToMultiByte(936, WC_DEFAULTCHAR, L"中文", -1, MbStr, 32, NULL, NULL); printf("%s\n", MbStr); return 0;}the output(wrong):Code: [Select])Press any key to continue...