X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fdocstream.cpp;h=e8839e07f61420104c3ff49826f7dc4997123ce6;hb=36e5864a8264b428ee7a59a09b25830b49d9c5af;hp=9edd9f27c6e8862710e4e43b41014d269b3074c9;hpb=7fec736162fac18f3c1f704f94f6967223fcccf6;p=lyx.git diff --git a/src/support/docstream.cpp b/src/support/docstream.cpp index 9edd9f27c6..e8839e07f6 100644 --- a/src/support/docstream.cpp +++ b/src/support/docstream.cpp @@ -512,76 +512,14 @@ otexstream & operator<<(otexstream & ots, docstring const & s) otexstream & operator<<(otexstream & ots, string const & s) { - ots << s.c_str(); + ots << from_utf8(s); return ots; } -namespace { - -int findToken(char const * s, char const * search_token) -{ - char const * token = strstr(s, search_token); - if (token) - return token - s; - return -1; -} - -} // namespace anon - - otexstream & operator<<(otexstream & ots, char const * s) { - size_t const len = strlen(s); - - // Check whether there's something to output - if (len == 0) - return ots; - - if (ots.protectSpace()) { - if (!ots.canBreakLine() && s[0] == ' ') - ots.os() << "{}"; - ots.protectSpace(false); - } - - char const * start_token = "\xf3\xb0\x80\x80"; - char const * end_token = "\xf3\xb0\x80\x81"; - - int i = findToken(s, start_token); - - if (i >= 0) { - // Some encoding changes for the underlying stream are embedded - // in the string. The encoding names to be used are enclosed - // between the code points 0xF0000 and xF0001 (0xf3b08080 and - // 0xf3b08081 in utf8 encoding). These code points belong to - // the plane 15 Private Use Area and have no associated glyph. - string s1(s, i); - char const * s2 = s + i + 4; - while (true) { - if (!s1.empty()) - ots.os() << from_utf8(s1); - if (s2[0] == '\0') - break; - i = findToken(s2, end_token); - if (i >= 0) { - ots.os() << setEncoding(string(s2, i)); - s2 += i + 4; - } - i = findToken(s2, start_token); - if (i >= 0) { - s1 = string(s2, i); - s2 += i + 4; - } else { - s1 = s2; - s2 += strlen(s2); - } - } - } else - ots.os() << s; - - ots.lastChar(s[len - 1]); - ots.texrow().newlines(count(s, s + len, '\n')); - ots.canBreakLine(s[len - 1] != '\n'); + ots << from_utf8(s); return ots; }