#include <limits.h>
#include <errno.h>
#include <pthread.h>
+#include <locale.h>
+#include <string.h>
+
+static bool utf8_output_supported;
+
+LTTNG_HIDDEN
+bool locale_supports_utf8(void)
+{
+ return utf8_output_supported;
+}
LTTNG_HIDDEN
int timespec_to_ms(struct timespec ts, unsigned long *ms)
res.tv_nsec = diff % (uint64_t) NSEC_PER_SEC;
return res;
}
+
+static
+void __attribute__((constructor)) init_locale_utf8_support(void)
+{
+ const char *program_locale = setlocale(LC_ALL, NULL);
+ const char *lang = getenv("LANG");
+
+ if (program_locale && strstr(program_locale, "utf8")) {
+ utf8_output_supported = true;
+ } else if (lang && strstr(lang, "utf8")) {
+ utf8_output_supported = true;
+ }
+}