GNOME Bugzilla – Bug 708408
libxml2 outputs decimal numbers in a localized format
Last modified: 2021-07-05 13:25:43 UTC
Using libexslt (math extension) and libxml2, the results of transformation functions (e.g. math:sin()) return the number in a localized format (e.g. 56,23 for the hu_HU.UTF-8 locale) instead of POSIX (56.23). I use libxml2 2.9.1 and libxslt 1.1.28, both shipped with Fedora 19 ATM.
Weird, can you attach a reproducing stylesheet. i checked EXSLT math code and it doesn't do formatting on its own so it's something related to libxml2 XPath, and i though it wasn't locale sensitive, well I tried hard to avoid locale setting impact, maybe that was broken by mistake. Daniel
As far as I can tell, the problem is in libxml2/xpath.c:xmlXPathFormatNumber() where it uses snprintf with %e or %f format, which will produce the locale dependent output. There is code in glib (g_ascii_formatd) for this that could be adapted here.
Closing this bug report as no further information has been provided. Please feel free to report this at https://gitlab.gnome.org if you can provide the information that was asked for in a previous comment and if this still happens in a recent and supported version. Thanks!
As explained in comment 2, this happens when switching to a non-English locale. This could be fixed by temporarily switching to the C locale with uselocale before calling snprintf.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.