fix for windows utf-8 input (#840)

Use UTF-16 as input on Windows, since UTF-8 does not work and reads multibyte characters as zeros
This commit is contained in:
Tomáš Pazdiora 2023-04-08 17:49:39 +02:00 committed by GitHub
parent f2d1c47294
commit aaf3b23deb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View file

@ -386,10 +386,19 @@ int main(int argc, char ** argv) {
std::string line;
bool another_line = true;
do {
#if defined(_WIN32)
std::wstring wline;
if (!std::getline(std::wcin, wline)) {
// input stream is bad or EOF received
return 0;
}
win32_utf8_encode(wline, line);
#else
if (!std::getline(std::cin, line)) {
// input stream is bad or EOF received
return 0;
}
#endif
if (line.empty() || line.back() != '\\') {
another_line = false;
} else {