+
+
+int switchEncoding(odocstream & os, BufferParams const & bparams,
+ Encoding const & oldEnc, Encoding const & newEnc)
+{
+ // FIXME thailatex does not support the inputenc package, so we
+ // ignore switches from/to tis620-0 encoding here. This does of
+ // course only work as long as the non-thai text contains ASCII
+ // only, but it is the best we can do.
+ if ((bparams.inputenc == "auto" || bparams.inputenc == "default") &&
+ oldEnc.name() != newEnc.name() &&
+ oldEnc.name() != "ascii" && newEnc.name() != "ascii" &&
+ oldEnc.name() != "tis620-0" && newEnc.name() != "tis620-0") {
+ lyxerr[Debug::LATEX] << "Changing LaTeX encoding from "
+ << oldEnc.name() << " to "
+ << newEnc.name() << endl;
+ os << setEncoding(newEnc.iconvName());
+ if (bparams.inputenc != "default") {
+ docstring const inputenc(from_ascii(newEnc.latexName()));
+ os << "\\inputencoding{" << inputenc << '}';
+ return 16 + inputenc.length();
+ }
+ }
+ return 0;
+}
+
+} // namespace lyx