Results 1 to 6 of 6

Thread: Windows Language Related Crashes

  1. #1
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45

    Windows Language Related Crashes

    Now, recently as many are aware I entered the Ludum Dare 21 and had some trouble.

    Finally, the problem has been uncovered and I post this as a warning to future foreign developers...

    IF YOU USE SYSUTILS OR STRTOFLOAT and similar procedures read carefully:

    On continental translations such as French and I suspect German also, FLOATING POINT values in a string MUST have a , (COMMA) while on other translations it is a . (POINT).

    Using the inappropriate decimal separator will result in various and seemingly random access violation, runtime errors and the like.

    Sascha Willems: I remembered reading of this game (http://www.saschawillems.de/?page_id=89) and how it only ran on german versions of windows. This was in truth the link that must have snapped in my mind to test it on different languages of windows and it was a good choice too... I've spoken to a few other fellow Ludum Dare coders about this issue and they also report some odd behavior, however they used a try statement to avoid the fatal...

    MS, why you did this I have no clue, for NT 7, change it back! please?

    Not to take advantage of this, the source code for the above game would not be available would it as the problem may be solved and I've always wanted to play that damn cool looking game

    a very annoyed and semi-formal code_glitch that will in future install a fresh XP install for each new windows related task...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  2. #2
    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.

  3. #3
    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





  4. #4
    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.

  5. #5
    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.

  6. #6
    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
  •