utf8_helper.cpp
branchsync
changeset 369 2d02d1fc2218
parent 364 2259aa4c6a64
     1.1 --- a/utf8_helper.cpp	Thu Oct 24 11:01:07 2019 +0200
     1.2 +++ b/utf8_helper.cpp	Wed Nov 06 15:02:09 2019 +0100
     1.3 @@ -30,16 +30,18 @@
     1.4              }
     1.5              string result;
     1.6  
     1.7 -            int size = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, _wstr_normalized.c_str(), -1, NULL, 0, NULL, NULL);
     1.8 +            int size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, _wstr_normalized.c_str(), -1, NULL, 0, NULL, NULL);
     1.9              assert(size);
    1.10              if (size) {
    1.11                  char *buf = new char[size];
    1.12 -                WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, _wstr_normalized.c_str(), -1, buf, size, NULL, NULL);
    1.13 +                WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, _wstr_normalized.c_str(), -1, buf, size, NULL, NULL);
    1.14                  result = buf;
    1.15                  delete[] buf;
    1.16              }
    1.17 -            else
    1.18 -                throw out_of_range("input wstring is not valid while converting UTF-16 to UTF-8.");
    1.19 +            else {
    1.20 +                DWORD error = GetLastError();
    1.21 +                throw out_of_range("input wstring is not valid while converting UTF-16 to UTF-8. Error" + error);
    1.22 +            }
    1.23  
    1.24              return result;
    1.25          }