compare charset strings case-insensitively (and so avoid conversions between utf-8 and UTF-8 for example, see patch 1611068)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-12-24 13:36:22 +00:00
parent 338b2a02ce
commit 8605f9c571

View File

@@ -636,7 +636,7 @@ bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding, int fl
ctx.encoding = wxT("UTF-8"); // default in absence of encoding=""
ctx.conv = NULL;
#if !wxUSE_UNICODE
if ( encoding != wxT("UTF-8") && encoding != wxT("utf-8") )
if ( encoding.CmpNoCase(wxT("UTF-8")) != 0 )
ctx.conv = new wxCSConv(encoding);
#endif
ctx.removeWhiteOnlyNodes = (flags & wxXMLDOC_KEEP_WHITESPACE_NODES) == 0;
@@ -853,17 +853,23 @@ bool wxXmlDocument::Save(wxOutputStream& stream, int indentstep) const
wxString s;
wxMBConv *convMem = NULL;
wxMBConv *convMem = NULL,
*convFile;
#if wxUSE_UNICODE
wxMBConv *convFile = new wxCSConv(GetFileEncoding());
convFile = new wxCSConv(GetFileEncoding());
convMem = NULL;
#else
wxMBConv *convFile = NULL;
if ( GetFileEncoding() != GetEncoding() )
if ( GetFileEncoding().CmpNoCase(GetEncoding()) != 0 )
{
convFile = new wxCSConv(GetFileEncoding());
convMem = new wxCSConv(GetEncoding());
}
else // file and in-memory encodings are the same, no conversion needed
{
convFile =
convMem = NULL;
}
#endif
s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
@@ -873,10 +879,8 @@ bool wxXmlDocument::Save(wxOutputStream& stream, int indentstep) const
OutputNode(stream, GetRoot(), 0, convMem, convFile, indentstep);
OutputString(stream, wxT("\n"));
if ( convFile )
delete convFile;
if ( convMem )
delete convMem;
delete convFile;
delete convMem;
return true;
}