- fi = fsys.OpenFile(bookFull);
- if (fi == NULL)
- {
- wxLogError(_("Cannot open HTML help book: %s"), bookFull.c_str());
- return FALSE;
- }
- fsys.ChangePathTo(bookFull);
- s = fi->GetStream();
- sz = s->GetSize();
- buff = new char[sz + 1];
- buff[sz] = 0;
- s->Read(buff, sz);
- lineptr = buff;
-
- do {
- lineptr = ReadLine(lineptr, linebuf);
-
- if (strstr(linebuf, "Title=") == linebuf)
- title = linebuf + strlen("Title=");
- if (strstr(linebuf, "Default topic=") == linebuf)
- start = linebuf + strlen("Default topic=");
- if (strstr(linebuf, "Index file=") == linebuf)
- index = linebuf + strlen("Index file=");
- if (strstr(linebuf, "Contents file=") == linebuf)
- contents = linebuf + strlen("Contents file=");
- if (strstr(linebuf, "Charset=") == linebuf)
- charset = linebuf + strlen("Charset=");
- } while (lineptr != NULL);
- delete[] buff;
-
- wxFontEncoding enc;
- if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
- else enc = wxTheFontMapper->CharsetToEncoding(charset);
- bool rtval = AddBookParam(*fi, enc,
- title, contents, index, start, fsys.GetPath());
- delete fi;
- return rtval;
+ // 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;