+ hyperset += quoted_options;
+ }
+ hyperset = rtrim(hyperset,",");
+
+ // check if the hyperref settings use an encoding that exceeds
+ // ours. If so, we have to switch to utf8.
+ Encoding const * const enc = runparams.encoding;
+ docstring const hs = from_utf8(hyperset);
+ bool need_unicode = false;
+ if (enc) {
+ for (size_t n = 0; n < hs.size(); ++n) {
+ if (enc->latexChar(hs[n], true) != docstring(1, hs[n]))
+ need_unicode = true;
+ }
+ }
+
+ // use in \\usepackage parameter as not all options can be handled inside \\hypersetup
+ if (!hyperref_already_provided) {
+ opt = rtrim(opt, ",");
+ opt = "\\usepackage[" + opt + "]\n {hyperref}\n";
+
+ if (!hyperset.empty())
+ opt += "\\hypersetup{" + hyperset + "}\n";
+ } else
+ // only in case hyperref is already loaded by the current text class
+ // try to put it into hyperset
+ //
+ // FIXME: this still does not fix the cases where hyperref is loaded
+ // and the option is active only when part of usepackage parameter
+ // (e.g. pdfusetitle).
+ {
+ opt = "\\hypersetup{" + opt + hyperset + "}\n";
+ }
+
+ lines = int(count(opt.begin(), opt.end(), '\n'));
+
+ // hyperref expects utf8!
+ if (need_unicode && enc && enc->iconvName() != "UTF-8") {
+ os << "\\inputencoding{utf8}\n"
+ << setEncoding("UTF-8");
+ ++lines;