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. Other Discussions
  3. Clever Code
  4. Serialization does not use culture specific settings while serializing double value to XML.

Serialization does not use culture specific settings while serializing double value to XML.

Scheduled Pinned Locked Moved Clever Code
helpxmljson
4 Posts 4 Posters 2 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.
  • M Offline
    M Offline
    Mikitsi
    wrote on last edited by
    #1

    Hi, I had to do class which stored some information which were double values, and finally the class contents where serialized to XML. When I was reading the contents back to system from XML using XMLDocument, I got an error message which was saying that the input string was not in correct format. I used some time to figure out that the reason was the culture setting of my computer. There input language was English (US) - Finnish, and the regional settings were Finnish. When the XML was serialized to file, the separator in double value was '.' instead of ','. then when I was reading the value, the Double.Parse method expected finnish separator ',' instead of english '.'. Dont know that is there error in code which initializes the serializer, or is this bug. Of cource I expected the serializer to write the double value using culture specific separator. Mika K

    R W 2 Replies Last reply
    0
    • M Mikitsi

      Hi, I had to do class which stored some information which were double values, and finally the class contents where serialized to XML. When I was reading the contents back to system from XML using XMLDocument, I got an error message which was saying that the input string was not in correct format. I used some time to figure out that the reason was the culture setting of my computer. There input language was English (US) - Finnish, and the regional settings were Finnish. When the XML was serialized to file, the separator in double value was '.' instead of ','. then when I was reading the value, the Double.Parse method expected finnish separator ',' instead of english '.'. Dont know that is there error in code which initializes the serializer, or is this bug. Of cource I expected the serializer to write the double value using culture specific separator. Mika K

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Hi, I don't think its a bug. Probably a flaw that the default behavior cannot be overridden. It makes absoluetly sense that by default the neutral culture is uesd. Otherwise two computers with different cultural settings couldn't communicate via Remoting with each other. Robert

      B 1 Reply Last reply
      0
      • R Robert Rohde

        Hi, I don't think its a bug. Probably a flaw that the default behavior cannot be overridden. It makes absoluetly sense that by default the neutral culture is uesd. Otherwise two computers with different cultural settings couldn't communicate via Remoting with each other. Robert

        B Offline
        B Offline
        benjymous
        wrote on last edited by
        #3

        We saw something similar in our code - running in Spain, all the "."s in our data exporter became ","s The code that read these files was still expecting a "." though, so all went very odd

        1 Reply Last reply
        0
        • M Mikitsi

          Hi, I had to do class which stored some information which were double values, and finally the class contents where serialized to XML. When I was reading the contents back to system from XML using XMLDocument, I got an error message which was saying that the input string was not in correct format. I used some time to figure out that the reason was the culture setting of my computer. There input language was English (US) - Finnish, and the regional settings were Finnish. When the XML was serialized to file, the separator in double value was '.' instead of ','. then when I was reading the value, the Double.Parse method expected finnish separator ',' instead of english '.'. Dont know that is there error in code which initializes the serializer, or is this bug. Of cource I expected the serializer to write the double value using culture specific separator. Mika K

          W Offline
          W Offline
          wout de zeeuw
          wrote on last edited by
          #4

          ToString uses the current thread's CultureInfo by default. Always overload ToString(CultureInfo.InvariantCulture) for persisting to file. Similarly for parsing. For the UI it's ok to use the current culture info.

          Wout

          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