From b04edcaf5f172e384e3257af6506a238e35689e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 5 May 2007 18:55:05 +0000 Subject: [PATCH] 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 --- src/xml/xml.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index 61617537a9..e45136bcb6 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -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 -- 2.50.0