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