Skip to content

Use std::stringstream instead of snprintf() for double->string conversion #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2014

Conversation

cdunn2001
Copy link
Contributor

snprintf() will use the current LC_NUMERIC locale
for converting a double to a string,
which will use a , instead of a . in some locales (e.g. de_DE).
std::stringstream allows setting the locale to "C" to always get a ..
This occurs only for that stringstream instance; no global is
altered.

…sion

`snprintf()` will use the current `LC_NUMERIC` locale
for converting a double to a string,
which will use a `,` instead of a `.` in some locales (e.g. de_DE).
`std::stringstream` allows setting the locale to `"C"` to always get a `.`.
This occurs only for that `stringstream` instance; no global is
altered.
@cdunn2001 cdunn2001 merged this pull request into open-source-parsers:master Jul 9, 2014
@cdunn2001 cdunn2001 deleted the fix-locale branch July 9, 2014 18:42
cdunn2001 added a commit that referenced this pull request Jul 9, 2014
Use std::stringstream instead of snprintf() for double->string conversion
@cdunn2001
Copy link
Contributor Author

Hmmm. I think we also need:

str.setf(std::ios_base::fixed|std::ios_base::scientific, std::ios_base::floatfield);

@cdunn2001
Copy link
Contributor Author

Hmmm. That doesn't seem to work, despite the link. Anyway, our tests pass. Call it done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants