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:
@@ -337,9 +337,10 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile)
|
|||||||
|
|
||||||
wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
|
wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
|
||||||
{
|
{
|
||||||
#ifdef __VMS__ // On VMS I saw the problem that the home directory was appended
|
#ifdef __VMS__
|
||||||
// twice for the configuration file. Does that also happen for other
|
// On VMS I saw the problem that the home directory was appended
|
||||||
// platforms?
|
// twice for the configuration file. Does that also happen for
|
||||||
|
// other platforms?
|
||||||
wxString str = wxT( '.' );
|
wxString str = wxT( '.' );
|
||||||
#else
|
#else
|
||||||
wxString str = GetLocalDir();
|
wxString str = GetLocalDir();
|
||||||
@@ -359,6 +360,7 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
|
|||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
str << " Preferences";
|
str << " Preferences";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,31 +376,45 @@ void wxFileConfig::Init()
|
|||||||
m_linesHead =
|
m_linesHead =
|
||||||
m_linesTail = NULL;
|
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
|
// parse the global file
|
||||||
if ( !m_strGlobalFile.IsEmpty() && wxFile::Exists(m_strGlobalFile) ) {
|
if ( !m_strGlobalFile.IsEmpty() && wxFile::Exists(m_strGlobalFile) )
|
||||||
|
{
|
||||||
wxTextFile fileGlobal(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 */);
|
Parse(fileGlobal, FALSE /* global */);
|
||||||
SetRootPath();
|
SetRootPath();
|
||||||
}
|
}
|
||||||
else
|
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
|
// parse the local file
|
||||||
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) ) {
|
if ( !m_strLocalFile.IsEmpty() && wxFile::Exists(m_strLocalFile) )
|
||||||
|
{
|
||||||
wxTextFile fileLocal(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 */);
|
Parse(fileLocal, TRUE /* local */);
|
||||||
SetRootPath();
|
SetRootPath();
|
||||||
}
|
}
|
||||||
else
|
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
|
// Make up names for files if empty
|
||||||
if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
|
if ( m_strLocalFile.IsEmpty() && (style & wxCONFIG_USE_LOCAL_FILE) )
|
||||||
{
|
|
||||||
m_strLocalFile = GetLocalFileName(GetAppName());
|
m_strLocalFile = GetLocalFileName(GetAppName());
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_strGlobalFile.IsEmpty() && (style & wxCONFIG_USE_GLOBAL_FILE) )
|
if ( m_strGlobalFile.IsEmpty() && (style & wxCONFIG_USE_GLOBAL_FILE) )
|
||||||
{
|
|
||||||
m_strGlobalFile = GetGlobalFileName(GetAppName());
|
m_strGlobalFile = GetGlobalFileName(GetAppName());
|
||||||
}
|
|
||||||
|
|
||||||
// Check if styles are not supplied, but filenames are, in which case
|
// Check if styles are not supplied, but filenames are, in which case
|
||||||
// add the correct styles.
|
// add the correct styles.
|
||||||
@@ -546,7 +558,9 @@ void wxFileConfig::Parse(wxTextBuffer& buffer, bool bLocal)
|
|||||||
wxString strLine;
|
wxString strLine;
|
||||||
|
|
||||||
size_t nLineCount = buffer.GetLineCount();
|
size_t nLineCount = buffer.GetLineCount();
|
||||||
for ( size_t n = 0; n < nLineCount; n++ ) {
|
|
||||||
|
for ( size_t n = 0; n < nLineCount; n++ )
|
||||||
|
{
|
||||||
strLine = buffer[n];
|
strLine = buffer[n];
|
||||||
|
|
||||||
// add the line to linked list
|
// add the line to linked list
|
||||||
|
Reference in New Issue
Block a user