gazebosim/gz-common

Helper functions for conversions that are locale independent

Open

#233 opened on Jul 26, 2021

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C++ (59 forks)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (28 stars)
PR merge metrics
 (PR metrics pending)

Description

Desired behavior

Different software in the Ignition family uses all kind of C/C++ functions to convert between types that are locale dependent and make functionality to fail under non C locales. Examples are:

Trying to complete the list (split due to limitations in github search) based on https://www.gnu.org/software/libc/manual/html_node/Parsing-of-Numbers.html:

Alternatives considered

There is a native function in C++17 https://en.cppreference.com/w/cpp/utility/to_chars which is not available in all supported platforms at this time. The boost::lexical_cast could be an option but would be ideal not to depend on boost if possible.

Implementation suggestion

I think that the best approach would be to implement helper functions that encapsulate the implementation in this ign-common repository. The implementation can rely on to_chars if C++17 is available or use other workarounds (see https://github.com/ros/urdfdom_headers/pull/42).

A similar work was done for sdformat years ago. Following the locale_fix test can lead to details.

Contributor guide