| 60 | } |
| 61 | |
| 62 | static bool FindAnsiRoundtripSample(wchar_t* sample, uint32_t sample_len) |
| 63 | { |
| 64 | const wchar_t* candidates[] = |
| 65 | { |
| 66 | L"\x00E9", // e acute |
| 67 | L"\x00F6", // o diaeresis |
| 68 | L"\x00DF", // sharp s |
| 69 | L"\x0416", // Cyrillic |
| 70 | L"\x3042", // Japanese Hiragana |
| 71 | L"\x65E5", // CJK |
| 72 | L"\xD55C", // Korean |
| 73 | }; |
| 74 | |
| 75 | char acp[16]; |
| 76 | char utf8[16]; |
| 77 | wchar_t roundtrip[16]; |
| 78 | |
| 79 | for (uint32_t i = 0; i < sizeof(candidates) / sizeof(candidates[0]); ++i) |
| 80 | { |
| 81 | if (!WideToCodePage(CP_ACP, candidates[i], acp, sizeof(acp))) |
| 82 | continue; |
| 83 | if (!WidePathToUtf8(candidates[i], utf8, sizeof(utf8))) |
| 84 | continue; |
| 85 | if (strcmp(acp, utf8) == 0) |
| 86 | continue; |
| 87 | if (!CodePageToWide(CP_ACP, acp, roundtrip, sizeof(roundtrip) / sizeof(roundtrip[0]))) |
| 88 | continue; |
| 89 | if (wcscmp(roundtrip, candidates[i]) != 0) |
| 90 | continue; |
| 91 | |
| 92 | wcscpy_s(sample, sample_len, candidates[i]); |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | static void WriteWideDebugLine(const wchar_t* prefix, const wchar_t* value) |
| 100 | { |
no test coverage detected