]> git.saurik.com Git - wxWidgets.git/commitdiff
Corrected code that re-encodes the book title.
authorJulian Smart <julian@anthemion.co.uk>
Mon, 1 Apr 2013 19:38:54 +0000 (19:38 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 1 Apr 2013 19:38:54 +0000 (19:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/html/helpdata.cpp

index e4ef62a1d5a264a9e3d09deca48d302b7e5b81ba..0b67e4482e6be6149ba9df4ca74a9578468e1efa 100644 (file)
@@ -500,6 +500,18 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
                                   const wxString& indexfile, const wxString& deftopic,
                                   const wxString& path)
 {
+#if wxUSE_WCHAR_T
+        #if wxUSE_UNICODE
+            #define CORRECT_STR(str, conv) \
+                str = wxString((str).mb_str(wxConvISO8859_1), conv)
+        #else
+            #define CORRECT_STR(str, conv) \
+                str = wxString((str).wc_str(conv), wxConvLocal)
+        #endif
+#else
+    #define CORRECT_STR(str, conv)
+#endif
+
     wxFileSystem fsys;
     wxFSFile *fi;
     wxHtmlBookRecord *bookr;
@@ -517,7 +529,16 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
             return true; // book is (was) loaded
     }
 
-    bookr = new wxHtmlBookRecord(bookfile.GetLocation(), fsys.GetPath(), title, deftopic);
+    wxString title1 = title;
+    if (encoding != wxFONTENCODING_SYSTEM)
+    {
+        wxCSConv conv(encoding);
+        CORRECT_STR(title1, conv);
+        if (title1.IsEmpty() && !title.IsEmpty())
+            title1 = title;
+    }
+
+    bookr = new wxHtmlBookRecord(bookfile.GetLocation(), fsys.GetPath(), title1, deftopic);
 
     wxHtmlHelpDataItem *bookitem = new wxHtmlHelpDataItem;
     bookitem->level = 0;
@@ -574,13 +595,6 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
     // differences here and also convert to wxConvLocal in ANSI build
     if (encoding != wxFONTENCODING_SYSTEM)
     {
-        #if wxUSE_UNICODE
-            #define CORRECT_STR(str, conv) \
-                str = wxString((str).mb_str(wxConvISO8859_1), conv)
-        #else
-            #define CORRECT_STR(str, conv) \
-                str = wxString((str).wc_str(conv), wxConvLocal)
-        #endif
         wxCSConv conv(encoding);
         size_t IndexCnt = m_index.size();
         size_t ContentsCnt = m_contents.size();
@@ -685,19 +699,6 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
         enc = wxFontMapper::Get()->CharsetToEncoding(charset);
 #endif
 
-    // No conversion was done on the title yet; at least
-    // test for a common case.
-    if (charset == wxT("utf-8") && !title.IsEmpty())
-    {
-        char *buf = new char[title.Length()+1];
-        size_t i;
-        for (i = 0; i < title.Length(); i++)
-            buf[i] = (char) title[i];
-        buf[i] = 0;
-        title = wxString::FromUTF8(buf);
-        delete[] buf;
-    }
-
     bool rtval = AddBookParam(*fi, enc,
                               title, contents, index, start, fsys.GetPath());
     delete fi;