[Kmymoney-devel] Another locale puzzle - CSV Importer

Alvaro Soliverez asoliverez at kde.org
Fri May 30 15:58:58 UTC 2014


On Fri, May 30, 2014 at 12:44 PM, Thomas Baumgart <thb at net-bembel.de> wrote:

>
> Hmm, that still leaves a problem: you never know if the file the user has
> matches his locale. I've seen banks in Germany delivering CSV files with a dot
> as decimal symbol while we usually use a comma for that purpose. Since the
> same applies to QIF, I once wrote
>
> void MyMoneyQifProfile::scanNumeric(const QString& txt, QChar& decimal, QChar&
> thousands) const
>
> which scans the string to determine decimal and thousand separator characters.
> Once you have that, you could use regular Alkimia for what you want to do.
> Here's how:
>
>   QString inputVal;                    // your unknown input data
>   QChar decimal('.'), thousands;       // make the dot the default
>   scanNumeric(inputVal, decimal, thousands);
>   if(AlkValue(inputVal, decimal) == AlkValue(0)) {
>   }
>
> Since scanNumeric is not static either, simply make a copy of it in your
> class.
>
> Does that make sense?
>
>

Hi,
You could also move that method to KMyMoneyTools, so it's available
for general use.

Regards,
Alvaro


More information about the KMyMoney-devel mailing list