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
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__
{
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();
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();
// 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) )
#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);
{
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;