[Kmymoney-devel] Another locale puzzle - CSV Importer
Allan
agander93 at gmail.com
Sat May 31 10:10:32 UTC 2014
On 30/05/14 18:26, Allan wrote:
> <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
A minor update.
I had a probably silly idea that it could be some consequence of the
locale change so added a large delay after the locale change, but that
made no difference.
Then I output the country code and country each pass, but that just tied
in with the other output. However, it did change something. Now, The
first two passes showed the UK locale, and the other two showed the
French. So. none-the-wiser.
Back to the bug, I've now abandoned altogether any attempt to get
meaningful results using xxx.toDouble() and am just working with the
text values. I've more testing to do but, it's looking OK.
Allan
More information about the KMyMoney-devel
mailing list