Skip to content

Parser number conversion LOCALE bug #43

@simoneruffini

Description

@simoneruffini

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions