-
Notifications
You must be signed in to change notification settings - Fork 321
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
Improved String to Decimal parsing #3943
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading/understanding correctly, this corrects the number parsing to be locale aware, but is number writing also locale specific?
I think the best case for locale handling would be to follow the robustness principle aka "be conservative in what you send, be liberal in what you accept". In this context, I think that should look like locale independent parsing (i.e. can parse comma or period decimals), and optionally hard-coded locale writing (.trc/.mot/.sto files with period decimals only). That would ensure that users with any locale can read .trc/.mot/.sto files generated anywhere, and (with hard-coded period decimal writing) ensure maximum compatibility reading .trc/.mot/.sto files by any third-party software/code (which might be less flexible with parsing).
This is in general a good idea but not possible in this specific instance. The file (at least all the imu
This parses as time as a decimal number seperated by a tab, followed by 4 values for each quaternion (separated by commas), then a tab, and repeat. So if it were acceptable to write or read numerics with commas you wouldn't know if the comma was a seperator between quaternions or a decimal place indicator. So in order to be able to accept numerics that use commas the file format would have to be changed. Per this comment it seems reasonable to not allow reading or writing commas in numerics. |
Updated to remove File IO changes and only include the minimal changes to |
These are great changes, and I'm glad someone's giving it a whack, but:
If I had a euro for every time a developer comes along and writes some version of this, I'd have Imo, drop the |
This seems like a reasonable enough refactor! The only thing I'd change is the static initialization of |
Nice work @alexbeattie42 👍 |
Fixes issue #3924
Brief summary of changes
String to Decimal Conversion
The above fixed the reading/writing problems but the code was still failing. Even with the imbuing of the input and output file stream, the parser converting strings to decimals is still using the system locale. After enough digging and exploration I found that
std::stod
is locale dependent. It is a thinly veiled wrapper ofstd::strtod
which does mention the locale dependance. To fix this issue I did the following:std::stod
in theIO.h
classstd::stod
with the newIO::stod
methodisstream
method (standard c++):Testing I've completed
Looking for feedback on...
CHANGELOG.md (choose one)
This change is