]> git.lyx.org Git - lyx.git/blobdiff - src/support/lstrings.cpp
Use HAVE_LONG_LONG_INT instead of LYX_USE_LONG_LONG
[lyx.git] / src / support / lstrings.cpp
index be326c0fd46dea68b7b229130b488fe9f3518fd3..3195762a4a280fd9d0cdc5133bd21f180f098705 100644 (file)
@@ -164,6 +164,26 @@ bool isNumber(char_type c)
 }
 
 
+bool isEuropeanNumberSeparator(char_type c)
+{
+       if (!is_utf16(c))
+               // assume that no non-utf16 character is a numeral
+               // c outside the UCS4 range is catched as well
+               return false;
+       return ucs4_to_qchar(c).direction() == QChar::DirES;
+}
+
+
+bool isEuropeanNumberTerminator(char_type c)
+{
+       if (!is_utf16(c))
+               // assume that no non-utf16 character is a numeral
+               // c outside the UCS4 range is catched as well
+               return false;
+       return ucs4_to_qchar(c).direction() == QChar::DirET;
+}
+
+
 bool isDigitASCII(char_type c)
 {
        return '0' <= c && c <= '9';
@@ -1431,6 +1451,14 @@ std::string formatFPNumber(double x)
 }
 
 
+docstring to_percent_encoding(docstring const & in, docstring const & ex)
+{
+       QByteArray input = toqstr(in).toUtf8();
+       QByteArray excludes = toqstr(ex).toUtf8();
+       return qstring_to_ucs4(QString(input.toPercentEncoding(excludes)));
+}
+
+
 docstring bformat(docstring const & fmt, int arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1447,7 +1475,7 @@ docstring bformat(docstring const & fmt, long arg1)
 }
 
 
-#ifdef LYX_USE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
 docstring bformat(docstring const & fmt, long long arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1547,5 +1575,22 @@ docstring bformat(docstring const & fmt,
        return subst(str, from_ascii("%%"), from_ascii("%"));
 }
 
+docstring bformat(docstring const & fmt, docstring const & arg1,
+                                 docstring const & arg2, docstring const & arg3,
+                                 docstring const & arg4, docstring const & arg5)
+{
+       LATTEST(contains(fmt, from_ascii("%1$s")));
+       LATTEST(contains(fmt, from_ascii("%2$s")));
+       LATTEST(contains(fmt, from_ascii("%3$s")));
+       LATTEST(contains(fmt, from_ascii("%4$s")));
+       LATTEST(contains(fmt, from_ascii("%5$s")));
+       docstring str = subst(fmt, from_ascii("%1$s"), arg1);
+       str = subst(str, from_ascii("%2$s"), arg2);
+       str = subst(str, from_ascii("%3$s"), arg3);
+       str = subst(str, from_ascii("%4$s"), arg4);
+       str = subst(str, from_ascii("%5$s"), arg5);
+       return subst(str, from_ascii("%%"), from_ascii("%"));
+}
+
 } // namespace support
 } // namespace lyx