]> git.lyx.org Git - lyx.git/blobdiff - src/support/docstring.cpp
add onoff support for "inset-modify changetype xxx" in include inset
[lyx.git] / src / support / docstring.cpp
index 7f56557899fcc7043303ed780596a08d869e92f7..b3417f7f26cd6a889a5e7d73f2a566eae4ccaf7b 100644 (file)
@@ -31,9 +31,13 @@ namespace lyx {
 docstring const from_ascii(char const * ascii)
 {
        docstring s;
-       for (char const * c = ascii; *c; ++c) {
-               LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
-               s.push_back(*c);
+       if (int n = strlen(ascii)) {
+               s.resize(n);
+               char_type *d = &s[0];
+               while (--n >= 0) {
+                       d[n] = ascii[n];
+                       LASSERT(static_cast<unsigned char>(ascii[n]) < 0x80, /**/);
+               }
        }
        return s;
 }
@@ -99,8 +103,7 @@ docstring const from_utf8(string const & utf8)
 
 string const to_utf8(docstring const & ucs4)
 {
-       vector<char> const utf8 =
-               ucs4_to_utf8(ucs4.data(), ucs4.size());
+       vector<char> const utf8 = ucs4_to_utf8(ucs4.data(), ucs4.size());
        return string(utf8.begin(), utf8.end());
 }