}
+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();
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);
}