- do
- {
- lineptr = ReadLine(lineptr, linebuf, 300);
-
- for (char *ch = linebuf; *ch != '\0' && *ch != '='; ch++)
- *ch = tolower(*ch);
-
- 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);
-
- wxFontEncoding enc;
- if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
- else enc = wxFontMapper::Get()->CharsetToEncoding(charset);
- bool rtval = AddBookParam(*fi, enc,
- title, contents, index, start, fsys.GetPath());
- delete fi;
- return rtval;
+ do
+ {
+ lineptr = ReadLine(lineptr, linebuf, 300);
+
+ for (wxChar *ch = linebuf; *ch != wxT('\0') && *ch != wxT('='); ch++)
+ *ch = (wxChar)wxTolower(*ch);
+
+ if (wxStrstr(linebuf, wxT("title=")) == linebuf)
+ title = linebuf + wxStrlen(wxT("title="));
+ if (wxStrstr(linebuf, wxT("default topic=")) == linebuf)
+ start = linebuf + wxStrlen(wxT("default topic="));
+ if (wxStrstr(linebuf, wxT("index file=")) == linebuf)
+ index = linebuf + wxStrlen(wxT("index file="));
+ if (wxStrstr(linebuf, wxT("contents file=")) == linebuf)
+ contents = linebuf + wxStrlen(wxT("contents file="));
+ if (wxStrstr(linebuf, wxT("charset=")) == linebuf)
+ charset = linebuf + wxStrlen(wxT("charset="));
+ } while (lineptr != NULL);
+
+ wxFontEncoding enc = wxFONTENCODING_SYSTEM;
+#if wxUSE_FONTMAP
+ if (charset != wxEmptyString)
+ 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;