+ // Switch file encoding if necessary
+ if (bparams.inputenc == "auto") {
+ // Look ahead for future encoding changes.
+ // We try to output them at the beginning of the paragraph,
+ // since the \inputencoding command is not allowed e.g. in
+ // sections.
+ for (pos_type i = 0; i < pit->size(); ++i) {
+ char_type const c = pit->getChar(i);
+ if (c < 0x80)
+ continue;
+ if (pit->isInset(i))
+ break;
+ // All characters before c are in the ASCII range, and
+ // c is non-ASCII (but no inset), so change the
+ // encoding to that required by the language of c.
+ Encoding const * const encoding =
+ pit->getFontSettings(bparams, i).language()->encoding();
+ if (switchEncoding(os, bparams, false,
+ *(runparams.encoding), *encoding) > 0) {
+ runparams.encoding = encoding;
+ os << '\n';
+ texrow.newline();
+ }
+ break;
+ }
+ }
+