+ // Prevent to paste uncodable characters in verbatim and ERT.
+ // The encoding is inherited from the context here.
+ docstring uncodable_content;
+ if (target_inset->getLayout().isPassThru() && cur.getEncoding()) {
+ odocstringstream res;
+ Encoding const * e = cur.getEncoding();
+ for (size_t i = 0; i != insertion.size(); ++i) {
+ pos_type end = insertion[i].size();
+ for (pos_type j = 0; j != end; ++j) {
+ char_type const c = insertion[i].getChar(j);
+ if (!e->encodable(c)) {
+ // do not track deletion
+ res << c;
+ insertion[i].eraseChar(j, false);
+ --end;
+ --j;
+ }
+ }
+ }
+ docstring const uncodable = res.str();
+ if (!uncodable.empty()) {
+ if (uncodable.size() == 1)
+ uncodable_content = bformat(_("The character \"%1$s\" is uncodable in this verbatim context "
+ "and thus has not been pasted."),
+ uncodable);
+ else
+ uncodable_content = bformat(_("The characters \"%1$s\" are uncodable in this verbatim context "
+ "and thus have not been pasted."),
+ uncodable);
+ }
+ }
+