Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Decimal point in floating point number in CSV under European locale

Decimal point in floating point number in CSV under European locale

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelpquestionannouncement
4 Posts 2 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shao Voon Wong
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • S Shao Voon Wong

      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.

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      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 and 246.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

      S 1 Reply Last reply
      0
      • P Peter_in_2780

        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 and 246.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

        S Offline
        S Offline
        Shao Voon Wong
        wrote on last edited by
        #3

        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)

        P 1 Reply Last reply
        0
        • S Shao Voon Wong

          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)

          P Offline
          P Offline
          Peter_in_2780
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups