-
May 26th, 2011, 05:17 PM
#1
_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)?
-
May 27th, 2011, 02:40 AM
#2
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
-
May 27th, 2011, 12:05 PM
#3
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.
-
May 27th, 2011, 04:22 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|