]> git.lyx.org Git - lyx.git/blobdiff - src/support/docstring.cpp
LyX 2.1 will support only Qt>=4.5.
[lyx.git] / src / support / docstring.cpp
index b3417f7f26cd6a889a5e7d73f2a566eae4ccaf7b..c937ba3721a1157bd2acff7d0bc754b74b0e614e 100644 (file)
@@ -25,6 +25,7 @@
 
 using namespace std;
 
+using lyx::support::isHexChar;
 
 namespace lyx {
 
@@ -132,7 +133,7 @@ string const to_local8bit(docstring const & s)
        if (s.empty())
                return string();
        QByteArray const local = toqstr(s).toLocal8Bit();
-       if (local.size() == 0)
+       if (local.isEmpty())
                throw to_local8bit_failure();
        return string(local.begin(), local.end());
 }
@@ -152,6 +153,22 @@ string const to_filesystem8bit(docstring const & s)
 }
 
 
+string const to_iconv_encoding(docstring const & s, string const & encoding)
+{
+       std::vector<char> const encoded =
+               ucs4_to_eightbit(s.data(), s.length(), encoding);
+       return string(encoded.begin(), encoded.end());
+}
+
+
+docstring const from_iconv_encoding(string const & s, string const & encoding)
+{
+       std::vector<char_type> const ucs4 =
+               eightbit_to_ucs4(s.data(), s.length(), encoding);
+       return docstring(ucs4.begin(), ucs4.end());
+}
+
+
 docstring const normalize_c(docstring const & s)
 {
        return qstring_to_ucs4(toqstr(s).normalized(QString::NormalizationForm_C));
@@ -737,9 +754,9 @@ private:
        bool isNumpunct(lyx::char_type const c) const
        {
                /// Only account for the standard numpunct "C" locale facet.
-               return c < 0x80 && (c == '-' || c == '+' || isdigit(c)
-                       || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')
-                       || c == 'x' || c == 'X');
+               return c == '-' || c == '+'
+                       || c == 'x' || c == 'X'
+                       || isHexChar(c);
        }
 
        template <typename ValueType>