From 894d74dcc233b7f9a936767558f3e061593dd062 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Mar 2005 16:39:02 +0000 Subject: [PATCH 1/1] applied part of patch 1169925: fix errors with multibyte <-> wx conversions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33098 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/fileconf.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 7e0291e968..2cfdd601b5 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -505,7 +505,12 @@ wxFileConfig::wxFileConfig(wxInputStream &inStream, wxMBConv& conv) break; } - strTmp.append(wxConvertMB2WX(buf), inStream.LastRead()); + // FIXME: this is broken because if we have part of multibyte + // character in the buffer (and another part hasn't been + // read yet) we're going to lose data because of conversion + // errors + buf[inStream.LastRead()] = '\0'; + strTmp += conv.cMB2WX(buf); } while ( !inStream.Eof() ); @@ -1014,7 +1019,9 @@ bool wxFileConfig::Save(wxOutputStream& os, wxMBConv& conv) { wxString line = p->Text(); line += wxTextFile::GetEOL(); - if ( !os.Write(line.mb_str(conv), line.length()) ) + + wxCharBuffer buf(line.mb_str(conv)); + if ( !os.Write(buf, strlen(buf)) ) { wxLogError(_("Error saving user configuration data.")); -- 2.47.2