]> git.saurik.com Git - wxWidgets.git/commitdiff
applied part of patch 1169925: fix errors with multibyte <-> wx conversions
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Mar 2005 16:39:02 +0000 (16:39 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Mar 2005 16:39:02 +0000 (16:39 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33098 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/fileconf.cpp

index 7e0291e96839b59940649a06c43a5b10d88ba8b9..2cfdd601b57b6506b1b3757ea6ea5a7c4dff91e5 100644 (file)
@@ -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."));