+ bool encoding_switched = false;
+ Encoding const * const save_enc = runparams.encoding;
+
+ if (!runparams.encoding->hasFixedWidth()) {
+ // We need to switch to a singlebyte encoding, since the listings
+ // package cannot deal with multiple-byte-encoded glyphs
+ Language const * const outer_language =
+ (runparams.local_font != 0) ?
+ runparams.local_font->language()
+ : buffer().params().language;
+ // We try if there's a singlebyte encoding for the current
+ // language; if not, fall back to latin1.
+ Encoding const * const lstenc =
+ (outer_language->encoding()->hasFixedWidth()) ?
+ outer_language->encoding()
+ : encodings.fromLyXName("iso8859-1");
+ pair<bool, int> const c = switchEncoding(os, buffer().params(),
+ runparams, *lstenc, true);
+ runparams.encoding = lstenc;
+ encoding_switched = true;
+ }
+