From 9a4920b88f8378ee74ee03a052d707b23d522e77 Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Sun, 2 Apr 2000 20:45:18 +0000 Subject: [PATCH] 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 --- include/wx/ffile.h | 7 ++++--- include/wx/file.h | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/wx/ffile.h b/include/wx/ffile.h index 4695dc989b..24d0437fba 100644 --- a/include/wx/ffile.h +++ b/include/wx/ffile.h @@ -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(); diff --git a/include/wx/file.h b/include/wx/file.h index 89718b6120..d52ad5f423 100644 --- a/include/wx/file.h +++ b/include/wx/file.h @@ -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();