}
-bool isEuropeanNumberSeparator(char_type c)
+bool isCommonNumberSeparator(char_type c)
{
if (!is_utf16(c))
// assume that no non-utf16 character is a numeral
// c outside the UCS4 range is caught as well
return false;
- return ucs4_to_qchar(c).direction() == QChar::DirES;
+ return ucs4_to_qchar(c).direction() == QChar::DirCS;
}
}
+docstring capitalize(docstring const & s) {
+ docstring ret = s;
+ char_type t = uppercase(ret[0]);
+ ret[0] = t;
+ return ret;
+}
+
+
string const ascii_lowercase(string const & a)
{
string tmp(a);
}
+int wordCount(docstring const & d)
+{
+ docstring dt = trim(d);
+ if (dt.empty())
+ return 0;
+ int words = 1;
+ for (auto const & c : dt) {
+ if (isSpace(c))
+ words++;
+ }
+ return words;
+}
+
+
+
int count_bin_chars(string const & str)
{
QString const qstr = toqstr(str).simplified();
char_type hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
docstring enc;
- for (size_t i = 0; i < lab.length(); ++i) {
- char_type c = lab[i];
+ for (char_type const c : lab) {
if (c >= 128 || c == '=' || c == '%' || c == '#' || c == '$'
|| c == '}' || c == '{' || c == ']' || c == '[' || c == '&'
|| c == '\\') {
os << std::fixed;
// Prevent outputs of 23.4200000000000017 but output small numbers
// with at least 6 significant digits.
- double const logarithm = log10(fabs(x));
- os << std::setprecision(max(6 - iround(logarithm), 0)) << x;
+ int const precision = (x == 0.0) ? 0 : max(6 - iround(log10(fabs(x))), 0);
+ os << std::setprecision(precision) << x;
string result = os.str();
if (result.find('.') != string::npos) {
result = rtrim(result, "0");
docstring bformat(docstring const & fmt, char const * arg1, docstring const & arg2)
{
- LATTEST(contains(fmt, from_ascii("%1$s")));
- LATTEST(contains(fmt, from_ascii("%2$s")));
- docstring str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
- str = subst(str, from_ascii("%2$s"), arg2);
- return subst(str, from_ascii("%%"), from_ascii("%"));
+ return bformat(fmt, from_ascii(arg1), arg2);
}