[Kmymoney-devel] Another locale puzzle - CSV Importer

Allan agander93 at gmail.com
Fri May 30 17:26:16 UTC 2014


<snip>
>
> loc->readMoney() is supposed to return a double.  Using that one in a debug
> stream as you do, uses the standard Qt functions to convert it into a string
> (I doubt they are locale aware). So I expect the problem to be right there.
>
> What happens, if you use
>
>    qDebug() << QLocale::toCurrencyString(loc->readMoney(str, ok));
>
> or
>
>    qDebug() << QLocale::toString(loc->readMoney(str, ok), 'f', 2);
>
> Does that print the value with a comma? Or stick with KLocale::formatMoney().
> I am really not sure, what you try to achieve.
>

Just a strange result with this, after I had had to modify it, as I 
mentioned earlier, to this-

  QLocale qloc;
  qloc.setDefault(QLocale(QLocale::French));
  bool ok;
  ok = false;
  KLocale* kloc = KGlobal::locale();
  QString str = "123,45";
  qDebug() <<"A"<< qloc.toCurrencyString(kloc->readMoney(str, &ok));
  qDebug() <<"B"<< qloc.toString(kloc->readMoney(str, &ok), 'f', 2);

I patched that into what I'm working on, and it was executed four times, 
once per line out of the file.

The first pass produced this -
A "£123.45"
B "123.45"

and the next three produced this -
A "123,45 €"
B "123,45"

I haven't had a chance to investigate why the first differed.  Strange.

Allan


More information about the KMyMoney-devel mailing list