showIncludes.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _CRT_SECURE_NO_WARNINGS
  2. # define _CRT_SECURE_NO_WARNINGS
  3. #endif
  4. #if defined(_MSC_VER) && _MSC_VER >= 1928
  5. # pragma warning(disable : 5105) /* macro expansion warning in windows.h */
  6. #endif
  7. #include <windows.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. int main()
  11. {
  12. /* 'cl /showIncludes' encodes output in the console output code page. */
  13. unsigned int cp = GetConsoleOutputCP();
  14. /* 'cl /showIncludes' prints output in the VS language. */
  15. const char* vslang = getenv("VSLANG");
  16. if (!vslang) {
  17. fprintf(stderr, "VSLANG is not set.\n");
  18. return 1;
  19. }
  20. printf("Console output code page: %u\n", cp);
  21. printf("Console input code page: %u\n", GetConsoleCP());
  22. printf("ANSI code page: %u\n", GetACP());
  23. printf("OEM code page: %u\n", GetOEMCP());
  24. printf("VSLANG: %s\n", vslang);
  25. // German.
  26. if (strcmp(vslang, "1031") == 0) {
  27. if (cp == 437 || cp == 65001) {
  28. printf("Hinweis: Einlesen der Datei: C:\\foo.h\n");
  29. return 0;
  30. }
  31. }
  32. // English.
  33. if (strcmp(vslang, "1033") == 0) {
  34. if (cp == 437 || cp == 65001) {
  35. printf("Note: including file: C:\\foo.h\n");
  36. return 0;
  37. }
  38. }
  39. // French.
  40. if (strcmp(vslang, "1036") == 0) {
  41. if (cp == 437 || cp == 863) {
  42. printf("Remarque\xff: inclusion du fichier\xff: C:\\foo.h\n");
  43. return 0;
  44. }
  45. if (cp == 65001) {
  46. printf("Remarque\xc2\xa0: inclusion du fichier\xc2\xa0: C:\\foo.h\n");
  47. return 0;
  48. }
  49. }
  50. // Italian.
  51. if (strcmp(vslang, "1040") == 0) {
  52. if (cp == 437 || cp == 65001) {
  53. printf("Nota: file incluso C:\\foo.h\n");
  54. return 0;
  55. }
  56. }
  57. // Japanese.
  58. if (strcmp(vslang, "1041") == 0) {
  59. if (cp == 932) {
  60. printf("\x83\x81\x83\x82: "
  61. "\x83\x43\x83\x93\x83\x4e\x83\x8b\x81\x5b\x83\x68 "
  62. "\x83\x74\x83\x40\x83\x43\x83\x8b: C:\\foo.h\n");
  63. return 0;
  64. }
  65. if (cp == 65001) {
  66. printf("\xe3\x83\xa1\xe3\x83\xa2: \xe3\x82\xa4\xe3\x83\xb3"
  67. "\xe3\x82\xaf\xe3\x83\xab\xe3\x83\xbc\xe3\x83\x89 "
  68. "\xe3\x83\x95\xe3\x82\xa1\xe3\x82\xa4\xe3\x83\xab: C:\\foo.h\n");
  69. return 0;
  70. }
  71. }
  72. // Chinese.
  73. if (strcmp(vslang, "2052") == 0) {
  74. if (cp == 54936 || cp == 936) {
  75. printf("\xd7\xa2\xd2\xe2: "
  76. "\xb0\xfc\xba\xac\xce\xc4\xbc\xfe: C:\\foo.h\n");
  77. return 0;
  78. }
  79. if (cp == 65001) {
  80. printf("\xe6\xb3\xa8\xe6\x84\x8f: "
  81. "\xe5\x8c\x85\xe5\x90\xab\xe6\x96\x87\xe4\xbb\xb6: C:\\foo.h\n");
  82. return 0;
  83. }
  84. }
  85. fprintf(stderr, "No example showIncludes for this code page and VSLANG.\n");
  86. return 1;
  87. }