From 67de05a11c55c027d6c5522de0fa93e66e221df3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 23 Feb 2003 19:01:29 +0000 Subject: [PATCH] wxFileConfig in Unicode fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/fileconf.h | 8 ++++++-- src/common/fileconf.cpp | 27 ++++++++------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/include/wx/fileconf.h b/include/wx/fileconf.h index b0e0b0b917..f836f08c8f 100644 --- a/include/wx/fileconf.h +++ b/include/wx/fileconf.h @@ -120,11 +120,13 @@ public: const wxString& vendorName = wxT(""), const wxString& localFilename = wxT(""), const wxString& globalFilename = wxT(""), - long style = wxCONFIG_USE_LOCAL_FILE); + long style = wxCONFIG_USE_LOCAL_FILE, + wxMBConv& conv = wxConvUTF8); #if wxUSE_STREAMS // ctor that takes an input stream. - wxFileConfig(wxInputStream &inStream); + wxFileConfig(wxInputStream &inStream, + wxMBConv& conv = wxConvUTF8); #endif // wxUSE_STREAMS // dtor will save unsaved data @@ -207,6 +209,8 @@ private: wxFileConfigGroup *m_pRootGroup, // the top (unnamed) group *m_pCurrentGroup; // the current group + wxMBConv &m_conv; + #ifdef __UNIX__ int m_umask; // the umask to use for file creation #endif // __UNIX__ diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 0b884e942f..16b17cadfc 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -389,11 +389,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(m_conv/*ignored in ANSI build*/) ) { Parse(fileGlobal, FALSE /* global */); SetRootPath(); @@ -408,11 +404,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(m_conv/*ignored in ANSI build*/) ) { Parse(fileLocal, TRUE /* local */); SetRootPath(); @@ -427,11 +419,12 @@ void wxFileConfig::Init() // constructor supports creation of wxFileConfig objects of any type wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName, const wxString& strLocal, const wxString& strGlobal, - long style) + long style, wxMBConv& conv) : wxConfigBase(::GetAppName(appName), vendorName, strLocal, strGlobal, style), - m_strLocalFile(strLocal), m_strGlobalFile(strGlobal) + m_strLocalFile(strLocal), m_strGlobalFile(strGlobal), + m_conv(conv) { // Make up names for files if empty if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) ) @@ -474,7 +467,8 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName, #if wxUSE_STREAMS -wxFileConfig::wxFileConfig(wxInputStream &inStream) +wxFileConfig::wxFileConfig(wxInputStream &inStream, wxMBConv& conv) + : m_conv(conv) { // always local_file when this constructor is called (?) SetStyle(GetStyle() | wxCONFIG_USE_LOCAL_FILE); @@ -961,12 +955,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, m_conv) ) { wxLogError(_("can't write user configuration file.")); return FALSE; -- 2.45.2