]> git.lyx.org Git - lyx.git/blobdiff - src/support/docstring.C
remove unused stuff
[lyx.git] / src / support / docstring.C
index 2be4134c5c92d1c8c838b98d237fb331ec1f3698..5e8d05f715bc852294f085f68a0402c94f624d11 100644 (file)
@@ -57,14 +57,6 @@ std::string const to_ascii(docstring const & ucs4)
 
 void utf8_to_ucs4(std::string const & utf8, docstring & ucs4)
 {
-       // FIXME (Abdel 17/11/06): static data are evil!
-       // This function cannot be used in the final exit process on Mac because
-       // static data are already destroyed at this stage.
-       // One solution would be to instantiate the utf8 to ucs4 IconvProcessor as a 
-       // singleton inside the LyX main class to ensure that it does not get 
-       // destroyed too early.
-       static IconvProcessor iconv(ucs4_codeset, "UTF-8");
-
        size_t n = utf8.size();
        // as utf8 is a multi-byte encoding, there would be at most
        // n characters:
@@ -76,7 +68,7 @@ void utf8_to_ucs4(std::string const & utf8, docstring & ucs4)
        // basic_string::data() is not recognized by some old gcc version
        // so we use &(ucs4[0]) instead.
        char * outbuf = (char *)(&(ucs4[0]));
-       int bytes = iconv.convert(utf8.c_str(), n, outbuf, maxoutsize);
+       int bytes = utf8ToUcs4().convert(utf8.c_str(), n, outbuf, maxoutsize);
 
        // adjust to the real converted size
        ucs4.resize(bytes/4);
@@ -473,9 +465,14 @@ protected:
                std::ios_base::iostate & err, long & v) const
        {
                std::string s;
-               s.resize(64);
-               for (int i = 0; iit != eit && isNumpunct(*iit); ++i, ++iit)
-                       s[i] = static_cast<char>(*iit);
+               s.reserve(64);
+               for (; iit != eit && isNumpunct(*iit); ++iit)
+                       s += static_cast<char>(*iit);
+               // We add another character, not part of the numpunct facet,
+               // in order to avoid setting the eofbit in the stream state,
+               // which would prevent any further read. The space seems a
+               // good choice here.
+               s += ' ';
                string_num_get_facet f;
                f.get(s.begin(), s.end(), b, err, v);