Use UTF8 for writing file configuation data in

Unicode mode. I assume that the registry
    also will use Unicode in Unicode mode.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-10-20 12:45:51 +00:00
parent 09cb4267da
commit 7fcfab5e21

View File

@@ -337,9 +337,10 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile)
wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
{
#ifdef __VMS__ // On VMS I saw the problem that the home directory was appended
// twice for the configuration file. Does that also happen for other
// platforms?
#ifdef __VMS__
// On VMS I saw the problem that the home directory was appended
// twice for the configuration file. Does that also happen for
// other platforms?
wxString str = wxT( '.' );
#else
wxString str = GetLocalDir();
@@ -359,6 +360,7 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
#ifdef __WXMAC__
str << " Preferences";
#endif
return str;
}
@@ -374,31 +376,45 @@ void wxFileConfig::Init()
m_linesHead =
m_linesTail = NULL;
// it's not an error if (one of the) file(s) doesn't exist
// It's not an error if (one of the) file(s) doesn't exist.
// parse the global file
if ( !m_strGlobalFile.IsEmpty() && wxFile::Exists(m_strGlobalFile) ) {
if ( !m_strGlobalFile.IsEmpty() && wxFile::Exists(m_strGlobalFile) )
{
wxTextFile fileGlobal(m_strGlobalFile);
if ( fileGlobal.Open() ) {
#if defined(__WXGTK20__) && wxUSE_UNICODE
if ( fileGlobal.Open( wxConvUTF8 ) )
#else
if ( fileGlobal.Open() )
#endif
{
Parse(fileGlobal, FALSE /* global */);
SetRootPath();
}
else
wxLogWarning(_("can't open global configuration file '%s'."),
m_strGlobalFile.c_str());
{
wxLogWarning(_("can't open global configuration file '%s'."), m_strGlobalFile.c_str());
}
}
// parse the local file
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) ) {
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) )
{
wxTextFile fileLocal(m_strLocalFile);
if ( fileLocal.Open() ) {
#if defined(__WXGTK20__) && wxUSE_UNICODE
if ( fileLocal.Open( wxConvUTF8 ) )
#else
if ( fileLocal.Open() )
#endif
{
Parse(fileLocal, TRUE /* local */);
SetRootPath();
}
else
wxLogWarning(_("can't open user configuration file '%s'."),
m_strLocalFile.c_str());
{
wxLogWarning(_("can't open user configuration file '%s'."), m_strLocalFile.c_str() );
}
}
}
@@ -413,14 +429,10 @@ wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
{
// Make up names for files if empty
if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
{
m_strLocalFile = GetLocalFileName(GetAppName());
}
if ( m_strGlobalFile.IsEmpty() && (style & wxCONFIG_USE_GLOBAL_FILE) )
{
m_strGlobalFile = GetGlobalFileName(GetAppName());
}
// Check if styles are not supplied, but filenames are, in which case
// add the correct styles.
@@ -546,7 +558,9 @@ void wxFileConfig::Parse(wxTextBuffer& buffer, bool bLocal)
wxString strLine;
size_t nLineCount = buffer.GetLineCount();
for ( size_t n = 0; n < nLineCount; n++ ) {
for ( size_t n = 0; n < nLineCount; n++ )
{
strLine = buffer[n];
// add the line to linked list