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

strtod is locale dependent, so as xml_attribute::as_double and get_value_double #568

Closed
7ymekk opened this issue Jun 8, 2023 · 1 comment

Comments

@7ymekk
Copy link

7ymekk commented Jun 8, 2023

There're 2 main decimal separators: comma and dot:

https://en.wikipedia.org/wiki/Decimal_separator#Countries_using_decimal_comma

If you save XML on e.g. UK locale computer and send that to a person in PL, then double values are gonna be converted to INT

char decimalComma[] = "123,123";
char decimalPoint[] = "123.123";

qDebug() << "--------" << strtod(decimalComma, 0) << strtod(decimalPoint, 0);

output depends on a locale:

  • in PL, the output will be "123.123", "123"
  • in UK, the output will be "123", "123.123"

it would be great if pugixml would handle that internally. We use QByteArrayView::toDouble() as a bypass for now.

@7ymekk 7ymekk added the bug label Jun 8, 2023
@zeux
Copy link
Owner

zeux commented Jun 16, 2023

Duplicate of #469

@zeux zeux marked this as a duplicate of #469 Jun 16, 2023
@zeux zeux added duplicate and removed bug labels Jun 16, 2023
@zeux zeux closed this as not planned Won't fix, can't repro, duplicate, stale Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants