fork download
  1. #include <cstdio> // for printf, sprintf.
  2. #include <cstring> // for strchr.
  3. #include <tchar.h> // for _T.
  4. #include <Windows.h> // for MessageBox.
  5.  
  6. /*
  7. 実行方法
  8.  
  9. chcp 65001
  10. dir /b | test.exe
  11.  
  12. */
  13.  
  14. int main()
  15. {
  16. char buffer[1024] = {};
  17.  
  18. if ( std::fgets(buffer, 1024, stdin) != nullptr )
  19. {
  20. if ( auto *p = std::strchr(buffer, '\n') )
  21. *p = '\0';
  22.  
  23. char msg2[100];
  24. std::sprintf(msg2, "%02X %02X %02X %02X : %s",
  25. buffer[0] & 0xFF, buffer[1] & 0xFF, buffer[2] & 0xFF, buffer[3] & 0xFF, buffer);
  26. ::MessageBoxA(nullptr, msg2, "UNKO", MB_OK); // → E2 86 9D... (OK)
  27.  
  28. wchar_t msg3[100];
  29. if ( ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, buffer, -1, msg3, sizeof msg3 / sizeof *msg3) == 0 )
  30. {
  31. _tprintf(_T("text encoding conversion failed\n"));
  32. return ~0;
  33. }
  34. std::sprintf(msg2, " > %04X %04X %04X %04X",
  35. msg3[0] & 0xFFFF, msg3[1] & 0xFFFF, msg3[2] & 0xFFFF, msg3[3] & 0xFFFF);
  36. ::MessageBoxA(nullptr, msg2, "UNKO", MB_OK); // → 219D... (OK)
  37.  
  38. ::MessageBoxW(nullptr, msg3, L"UNKO", MB_OK);
  39. }
  40. }
  41.  
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:30: fatal error: tchar.h: No such file or directory
compilation terminated.
stdout
Standard output is empty