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:
@@ -65,10 +65,11 @@ public:
|
|||||||
// returns the number of bytes written
|
// returns the number of bytes written
|
||||||
size_t Write(const void *pBuf, size_t nCount);
|
size_t Write(const void *pBuf, size_t nCount);
|
||||||
// returns true on success
|
// returns true on success
|
||||||
bool Write(const wxString& s)
|
bool Write(const wxString& s, wxMBConv& conv = wxConvLibc)
|
||||||
{
|
{
|
||||||
size_t size = s.Len()*sizeof(wxChar);
|
wxWX2MBbuf buf = s.mb_str();
|
||||||
return Write(s.c_str(), size) == size;
|
size_t size = strlen(buf);
|
||||||
|
return Write((const char *) buf, size) == size;
|
||||||
}
|
}
|
||||||
// flush data not yet written
|
// flush data not yet written
|
||||||
bool Flush();
|
bool Flush();
|
||||||
|
@@ -99,10 +99,11 @@ public:
|
|||||||
// returns the number of bytes written
|
// returns the number of bytes written
|
||||||
size_t Write(const void *pBuf, size_t nCount);
|
size_t Write(const void *pBuf, size_t nCount);
|
||||||
// returns true on success
|
// returns true on success
|
||||||
bool Write(const wxString& s)
|
bool Write(const wxString& s, wxMBConv& conv = wxConvLibc)
|
||||||
{
|
{
|
||||||
size_t size = s.Len()*sizeof(wxChar);
|
const wxWX2MBbuf buf = s.mb_str(conv);
|
||||||
return Write(s.c_str(), size) == size;
|
size_t size = strlen(buf);
|
||||||
|
return Write((const char *) buf, size) == size;
|
||||||
}
|
}
|
||||||
// flush data not yet written
|
// flush data not yet written
|
||||||
bool Flush();
|
bool Flush();
|
||||||
|
Reference in New Issue
Block a user