X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/338dd992160bf20205743c092b353d96ef7604fb..7f82eb0018bfe00f882645e2d9de2ff2694f9d8c:/src/common/datstrm.cpp diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index 2ea158faae..5c4fd46091 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 28/06/98 // RCS-ID: $Id$ -// Copyright: (c) Guilhem Lavaux +// Copyright: (c) Guilhem Lavaux // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -86,22 +86,25 @@ double wxDataInputStream::ReadDouble() wxString wxDataInputStream::ReadString() { - wxString wx_string; - char *string; - unsigned long len; + size_t len; len = Read32(); - string = new char[len+1]; - m_input->Read(string, len); - - string[len] = 0; - wx_string = string; - delete string; +#if wxUSE_UNICODE + char *tmp = new char[len + 1]; + m_input->Read(tmp, len); + tmp[len] = 0; + wxString s(tmp); + delete[] tmp; +#else + wxString s; + m_input->Read(s.GetWriteBuf(len), len); + s.UngetWriteBuf(); +#endif - return wx_string; + return s; } - + wxDataInputStream& wxDataInputStream::operator>>(wxString& s) { s = ReadString(); @@ -285,4 +288,4 @@ wxDataOutputStream& wxDataOutputStream::operator<<(float f) #endif // wxUSE_STREAMS - +