Context: the units package adds support for measurement units to R, and uses udunits2 as the backend. Our users have detected this different behaviour on Windows (see r-quantities/units#301), which can be tracked down to ut_map_unit_to_symbol:
#include <stdio.h>
#include <udunits2/udunits2.h>
int main() {
ut_set_error_message_handler((ut_error_message_handler) ut_ignore);
ut_system *sys = ut_read_xml(NULL);
ut_encoding enc = UT_UTF8;
ut_set_error_message_handler((ut_error_message_handler) vprintf);
ut_unit *m = ut_parse(sys, "1 m", enc);
ut_map_symbol_to_unit("my_metre", enc, m);
// fails on Windows, works fine on Unix
ut_map_unit_to_symbol(m, "my_metre", enc);
// Error: Unit already maps to "m"
ut_free(m);
ut_free_system(sys);
return 0;
}
Apparently, this fails on Windows for "1 m", a 1-to-1 conversion, but not for others, like "2 m".
Context: the units package adds support for measurement units to R, and uses udunits2 as the backend. Our users have detected this different behaviour on Windows (see r-quantities/units#301), which can be tracked down to
ut_map_unit_to_symbol
:Apparently, this fails on Windows for "1 m", a 1-to-1 conversion, but not for others, like "2 m".