From 02272c9c3e902dbc910b702744b750d2b978f4bb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 11 Sep 2004 18:47:13 +0000 Subject: [PATCH] default MB -> WC conversion under Win32 now fails if it encounters invalid MB chars; this is more iconv-compatible and fixes wxTextInputStream::NextChar() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29095 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/strconv.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 6623da650c..7b39e4bb3f 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1148,10 +1148,15 @@ public: size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const { + // note that we have to use MB_ERR_INVALID_CHARS flag as it without it + // the behaviour is not compatible with the Unix version (using iconv) + // and break the library itself, e.g. wxTextInputStream::NextChar() + // wouldn't work if reading an incomplete MB char didn't result in an + // error const size_t len = ::MultiByteToWideChar ( m_CodePage, // code page - 0, // flags (none) + MB_ERR_INVALID_CHARS, // flags: fall on error psz, // input string -1, // its length (NUL-terminated) buf, // output string