Made wx[F]File::Write(wxString) convert string to multibyte encoding

(added optional conversion parameter). If someone actually wants to write
text files in real Unicode format, I feel that a wxMBConvUTF16 or
something should be written (which would be more portable than writing
wchar_t buffers directly, considering byte order and widths and such).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7036 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ove Kaaven
2000-04-02 20:45:18 +00:00
parent 8a2a71db83
commit 9a4920b88f
2 changed files with 8 additions and 6 deletions

View File

@@ -65,10 +65,11 @@ public:
// returns the number of bytes written
size_t Write(const void *pBuf, size_t nCount);
// returns true on success
bool Write(const wxString& s)
bool Write(const wxString& s, wxMBConv& conv = wxConvLibc)
{
size_t size = s.Len()*sizeof(wxChar);
return Write(s.c_str(), size) == size;
wxWX2MBbuf buf = s.mb_str();
size_t size = strlen(buf);
return Write((const char *) buf, size) == size;
}
// flush data not yet written
bool Flush();

View File

@@ -99,10 +99,11 @@ public:
// returns the number of bytes written
size_t Write(const void *pBuf, size_t nCount);
// returns true on success
bool Write(const wxString& s)
bool Write(const wxString& s, wxMBConv& conv = wxConvLibc)
{
size_t size = s.Len()*sizeof(wxChar);
return Write(s.c_str(), size) == size;
const wxWX2MBbuf buf = s.mb_str(conv);
size_t size = strlen(buf);
return Write((const char *) buf, size) == size;
}
// flush data not yet written
bool Flush();