Skip to content

Floating point URI arguments are not parsed correctly #8

Open
@Izzatbek

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions