From dc5003c6f31cd29c97b149e811676eebe9a234ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 7 Apr 2003 22:14:15 +0000 Subject: [PATCH] backported wxFileConfig fix for Unicode mode: always use utf-8 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20066 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/strconv.h | 3 ++- src/common/fileconf.cpp | 19 +++---------------- src/common/strconv.cpp | 3 ++- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 7d22b34c0a..afa67254cf 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -174,7 +174,8 @@ public: const char* cWX2MB(const char *psz) const { return psz; } }; -WXDLLEXPORT_DATA(extern wxMBConv) wxConvLibc, wxConvFile, wxConvLocal, wxConvISO8859_1; +WXDLLEXPORT_DATA(extern wxMBConv) wxConvLibc, wxConvFile, wxConvLocal, + wxConvISO8859_1, wxConvUTF8; WXDLLEXPORT_DATA(extern wxMBConv *) wxConvCurrent; #define wxFNCONV(name) name diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index fa8a95c6b8..8b92238d3d 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -384,11 +384,7 @@ void wxFileConfig::Init() { wxTextFile fileGlobal(m_strGlobalFile); -#if defined(__WXGTK20__) && wxUSE_UNICODE - if ( fileGlobal.Open( wxConvUTF8 ) ) -#else - if ( fileGlobal.Open() ) -#endif + if ( fileGlobal.Open(wxConvUTF8/*ignored in ANSI build*/) ) { Parse(fileGlobal, FALSE /* global */); SetRootPath(); @@ -403,11 +399,7 @@ void wxFileConfig::Init() if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) ) { wxTextFile fileLocal(m_strLocalFile); -#if defined(__WXGTK20__) && wxUSE_UNICODE - if ( fileLocal.Open( wxConvUTF8 ) ) -#else - if ( fileLocal.Open() ) -#endif + if ( fileLocal.Open(wxConvUTF8/*ignored in ANSI build*/) ) { Parse(fileLocal, TRUE /* local */); SetRootPath(); @@ -965,12 +957,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) { wxString line = p->Text(); line += wxTextFile::GetEOL(); -#if wxUSE_UNICODE - wxCharBuffer buf = wxConvLocal.cWX2MB( line ); - if ( !file.Write( (const char*)buf, strlen( (const char*) buf ) ) ) -#else - if ( !file.Write( line.c_str(), line.Len() ) ) -#endif + if ( !file.Write(line, wxConvUTF8) ) { wxLogError(_("can't write user configuration file.")); return FALSE; diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index a868a4a2ad..92c62856ff 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -58,7 +58,8 @@ WXDLLEXPORT_DATA(wxMBConv) wxConvLibc, wxConvFile, wxConvISO8859_1, - wxConvLocal; + wxConvLocal, + wxConvUTF8; #endif // wxUSE_WCHAR_T WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc;