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

Parser number conversion LOCALE bug #43

Open
simoneruffini opened this issue Apr 9, 2024 · 0 comments
Open

Parser number conversion LOCALE bug #43

simoneruffini opened this issue Apr 9, 2024 · 0 comments

Comments

@simoneruffini
Copy link

I found a "bug" in the parsing of numbers. As of now the parsing is handled by the following line:

auto number = std::stod(std::string{ sv.token() });

The problem is that std::stod converts data using your locale hrence if your locale has the comma (,) as the decimal separator the parsing will not work correctly since the DBC standard uses the dot ..
My locale is it_IT.UTF-8 and unfortunately the decimal separator is the comma.
When CANdb parses the following signal in the dbc file:

SG_ HVB_tCellMean : 23|16@0+ (0.01,-273.15) [-40|105] "degC" Charger,VCU

It will parse factor=0 instead of 0.04 and offset=-273 instead of -273.15

I changed my environment variable when using CANdb to en_US-UTF.8 and now it works.

I think the solution is to define the parsing locale in the libary itself or better: change the conversion function to not use locale at all.

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

No branches or pull requests

1 participant