use FromUTF8() when loading XML, data coming from Expat are already validated UTF-8

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-05 18:55:05 +00:00
parent 5f167b77d2
commit b04edcaf5f

View File

@@ -418,13 +418,9 @@ bool wxXmlDocument::Save(const wxString& filename, int indentstep) const
// converts Expat-produced string in UTF-8 into wxString using the specified
// conv or keep in UTF-8 if conv is NULL
static wxString CharToString(wxMBConv *conv,
const char *s, size_t len = wxString::npos)
const char *s, size_t len = wxString::npos)
{
#if wxUSE_UNICODE
wxUnusedVar(conv);
return wxString(s, wxConvUTF8, len);
#else // !wxUSE_UNICODE
#if !wxUSE_UNICODE
if ( conv )
{
// there can be no embedded NULs in this string so we don't need the
@@ -434,11 +430,11 @@ static wxString CharToString(wxMBConv *conv,
return wxString(wbuf, *conv);
}
else // already in UTF-8, no conversion needed
{
return wxString(s, len != wxString::npos ? len : strlen(s));
}
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
// else: the string is wanted in UTF-8
#endif // !wxUSE_UNICODE
wxUnusedVar(conv);
return wxString::FromUTF8(s, len);
}
// returns true if the given string contains only whitespaces