Decimal point in floating point number in CSV under European locale
-
I am saving a series of floating point numbers in CSV. I heard that under some European locale, the decimal point in floating point is actually a comma, I was wondering if I release this product in a European market, will my library have trouble parsing the floats since my decimal point is a full stop, not a comma. Does anyone encounter this problem in those locales? How do you handle it? Thanks in advance.
-
I am saving a series of floating point numbers in CSV. I heard that under some European locale, the decimal point in floating point is actually a comma, I was wondering if I release this product in a European market, will my library have trouble parsing the floats since my decimal point is a full stop, not a comma. Does anyone encounter this problem in those locales? How do you handle it? Thanks in advance.
Any decent CSV library should take care of this by quoting anything containing the field delimiter (in this case, comma). I just did a simple test with LibreOffice Calc: * entered
123.45
and246.80
in the first two cells. * changed its locale to German * saved as csv The result:"123,45","246,80"
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Any decent CSV library should take care of this by quoting anything containing the field delimiter (in this case, comma). I just did a simple test with LibreOffice Calc: * entered
123.45
and246.80
in the first two cells. * changed its locale to German * saved as csv The result:"123,45","246,80"
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
Thank you for your reply. How about parsing float numbers with full stops in German locale? I am not sure if the C++ stof() handles it since the C++ Reference page states it is determined by the current C locale. [std::stof, std::stod, std::stold - cppreference.com](https://en.cppreference.com/w/cpp/string/basic\_string/stof)
-
Thank you for your reply. How about parsing float numbers with full stops in German locale? I am not sure if the C++ stof() handles it since the C++ Reference page states it is determined by the current C locale. [std::stof, std::stod, std::stold - cppreference.com](https://en.cppreference.com/w/cpp/string/basic\_string/stof)
I haven't done anything serious in that area for at least a decade, but from memory you need to set the locale programmatically to be sure of where you are when you parse input.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012