Temporarily changing locale to C while generating the SVG image
With locales that have a character other than dot as a decimal separator, the generated SVG is messed up (due to a libxml2 bug)
This commit is contained in:
parent
3c3a09143b
commit
a154118b6f
@ -6,6 +6,7 @@
|
|||||||
#include <libxslt/xsltInternals.h>
|
#include <libxslt/xsltInternals.h>
|
||||||
#include <libxslt/transform.h>
|
#include <libxslt/transform.h>
|
||||||
#include <swe-glib.h>
|
#include <swe-glib.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#include "ag-chart.h"
|
#include "ag-chart.h"
|
||||||
|
|
||||||
@ -686,6 +687,7 @@ ag_chart_create_svg(AgChart *chart, GError **err)
|
|||||||
gint save_length;
|
gint save_length;
|
||||||
GFile *xslt_file;
|
GFile *xslt_file;
|
||||||
xsltStylesheetPtr xslt_proc;
|
xsltStylesheetPtr xslt_proc;
|
||||||
|
locale_t current_locale;
|
||||||
|
|
||||||
root_node = xmlDocGetRootElement(doc);
|
root_node = xmlDocGetRootElement(doc);
|
||||||
|
|
||||||
@ -855,7 +857,13 @@ ag_chart_create_svg(AgChart *chart, GError **err)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// libxml2 messes up the output, as it prints decimal floating point
|
||||||
|
// numbers in a localized format. It is not good in locales that use a
|
||||||
|
// character for decimal separator other than a dot. So let's just use the
|
||||||
|
// C locale until the SVG is generated.
|
||||||
|
current_locale = uselocale(newlocale(LC_ALL, "C", 0));
|
||||||
svg_doc = xsltApplyStylesheet(xslt_proc, doc, NULL);
|
svg_doc = xsltApplyStylesheet(xslt_proc, doc, NULL);
|
||||||
|
uselocale(current_locale);
|
||||||
g_free(stylesheet_path);
|
g_free(stylesheet_path);
|
||||||
xsltFreeStylesheet(xslt_proc);
|
xsltFreeStylesheet(xslt_proc);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
Loading…
Reference in New Issue
Block a user