}
+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';
namespace {
template<typename String> vector<String> const
-getVectorFromStringT(String const & str, String const & delim, bool keepempty)
+getVectorFromStringT(String const & str, String const & delim,
+ bool keepempty, bool trimit)
{
// Lars would like this code to go, but for now his replacement (below)
// doesn't fullfil the same function. I have, therefore, reactivated the
vector<String> vec;
if (str.empty())
return vec;
- String keys = rtrim(str);
+ String keys = trimit ? rtrim(str) : str;
while (true) {
size_t const idx = keys.find(delim);
if (idx == String::npos) {
- vec.push_back(ltrim(keys));
+ vec.push_back(trimit ? ltrim(keys) : keys);
break;
}
- String const key = trim(keys.substr(0, idx));
+ String const key = trimit ?
+ trim(keys.substr(0, idx)) : keys.substr(0, idx);
if (!key.empty() || keepempty)
vec.push_back(key);
size_t const start = idx + delim.size();
vector<string> const getVectorFromString(string const & str,
- string const & delim,
- bool keepempty)
+ string const & delim, bool keepempty, bool trimit)
{
- return getVectorFromStringT<string>(str, delim, keepempty);
+ return getVectorFromStringT<string>(str, delim, keepempty, trimit);
}
vector<docstring> const getVectorFromString(docstring const & str,
- docstring const & delim,
- bool keepempty)
+ docstring const & delim, bool keepempty, bool trimit)
{
- return getVectorFromStringT<docstring>(str, delim, keepempty);
+ return getVectorFromStringT<docstring>(str, delim, keepempty, trimit);
}
}
+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")));