Results 1 to 6 of 6

Thread: Windows Language Related Crashes

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Quote Originally Posted by code_glitch View Post
    MS, why you did this I have no clue, for NT 7, change it back! please?
    What Microsoft had to do with this?

    In the beginning of your program, use this: DecimalSeparator:= '.'; // or ","

    Also, properly written code shouldn't break because of this, if you use Try...Except statements for StrToFloat; StrToFloatDef will simply return default value if invalid character is found. Never seen access violations happen with these functions.

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    What on earth is a "Windows Language"? It's like having the "Delphi" vs "Object Pascal" name argument...
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3
    Well, as you hinted at I encountered those problems long time ago (I guess the first time a non-german user used one of my games).

    But there is a simple solution : Replace the decimal separator yourself before storing and loading values. This is what I now do in all my apps/games and this is how I do it :

    Saving values :
    - Convert floating point value to string
    - Replace the current decimal separator (stored in System.DecimalSeparator) with a '.' (always, no matter what language)
    - Save to e.g. XML-Node

    Loading values :
    - Get string
    - Replace all '.' with current decimal separator. So for e.g. german OS '.' will be replaced with ',', for all langauges using '.' nothing is changed
    - Convert back to float

    Another possibility would be to what LifePower mentioned, though I prefer the above one as I usually save/load to/from XML and it doesn't matter what value type you store to a node. And also this allows me to format my floats before saving them.

  4. #4
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Lifepower: If you query the NT kernel at the base of your XP and 7 installs and ask it to convert a string to a float, depending on the system language (in this case french) it returns the value it seems most appropriate for the langauge. I don't know if you knwo this but Microsoft makes a 'special' or rather custom built version of windows for french people to sell in france, german people for germany etc. Less so now with windows 7 and it being one installer where you choose the language, but many elements are similar to the garbage present on Windows 95 (I have a french install cd of that)... And that really only ran programs if they where french - and a LOT of stuff crashed.

    And now you have seen code break because of this.

    WILL: Windows language refers to the language the OS was aimed at, they make it easier to use by implementing umlauts and other grammatical symbols down to quite a low level - the . and , seperators being ported right down to NT level.

    Sascha: I have to admit that that is quite a lot of work for just converting a string to float on different languages of an OS - I mean you'd expect those things to only tweak the UI not the actual way in which code runs!

    I just started this thread because I know there are a lot of foreign languaged programmers here and just wanted them to know that sometimes languages do screw things up and as a reference so that no-one in the future goes through two days of garbage and have to install an XP VM in a different language just to try and debug a game...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #5
    i also uses if DecimalSeparator=','
    then DecimalSeparator:='.';

    And have no problem when the game is switched to french.
    Current (and lifetime) project: FAR Colony
    https://www.farcolony.com/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •