X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Ftime.c;h=5519e3ab4715240cfd1b27ef7701d36c1b737039;hp=5c5594584dc6ae37c59ab44625ca7ad9b8c9534d;hb=2a1135fa25ad1fcad3b395e795aa6d41afc90c54;hpb=645a0d9a7c5753b46b2bf239fea98b47729f5b14 diff --git a/src/common/time.c b/src/common/time.c index 5c5594584..5519e3ab4 100644 --- a/src/common/time.c +++ b/src/common/time.c @@ -22,6 +22,16 @@ #include #include #include +#include +#include + +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) @@ -57,3 +67,16 @@ struct timespec timespec_abs_diff(struct timespec t1, struct timespec t2) 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 (strstr(lang, "utf8")) { + utf8_output_supported = true; + } +}