Skip to content
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

Floating point URI arguments are not parsed correctly #8

Open
Izzatbek opened this issue Sep 7, 2016 · 0 comments
Open

Floating point URI arguments are not parsed correctly #8

Izzatbek opened this issue Sep 7, 2016 · 0 comments
Labels

Comments

@Izzatbek
Copy link
Collaborator

Izzatbek commented Sep 7, 2016

The function atof used in URI.cpp returns integer values for floating point numbers if an application uses locale where comma is used to separate the integer part.

Example:

URI uri("osx:?setting=1.5");
double setting = 0.;
URI::getQueryArg(uri.query, "setting", &setting);
// here setting maybe equal to 1 instead of 1.5

This can be corrected with

setlocale(LC_NUMERIC, "C")

before using the function, however we need to put the current locale back afterwards.

The easier option could be using istringstream to read the numbers, since it uses US locale by default.

@Izzatbek Izzatbek added the bug label Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant