CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    _ttof() for different locales

    Was just curious how does _ttof() behave for different locales?
    http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

    Does it just stick with US standard to parse a floating point number or is it specific for a locale of a current user (for say, instead of 1.23 in US it may be expecting 1,23 for some European locales)?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: _ttof() for different locales

    Do you suggest us to make such a test for you?
    What prevents you to test it yourself?
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: _ttof() for different locales

    No, I don't. I just want to make sure that it behaves like I expect it to. Otherwise it'd be too expensive to fix it post-date.

  4. #4
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: _ttof() for different locales

    After having done some digging around, I'm inclined to believe that it is much more safe to use _tstof_l() with a specific locale, for U.S. format, for instance, rather than leaving it up to chance. Here's a code example:
    Code:
    //Init locale (when app starts)
    _locale_t localeUS;
    localeUS = _create_locale(LC_ALL, "English_United States.1252");
    
    ...
    
    //Then, for say, de-serializing from a data file
    double f = _tstof_l(string, localeUS);
    
    ...
    //And the clean-up when app quits
    if(localeUS)
    	_free_locale(localeUS);

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured