diff --git a/src/lib/internal.h b/src/lib/internal.h index f01852462..be2b66ec2 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -35,6 +35,7 @@ const char* oiio_version(void); #include #include #include +#include #include "notcurses/notcurses.h" #include "egcpool.h" @@ -620,6 +621,19 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int update_term_dimensions(int fd, int* rows, int* cols); +// might not be particularly fast, use sparingly, ideally once +static inline bool +enforce_utf8(void){ + char* enc = nl_langinfo(CODESET); + if(!enc){ + return false; + } + if(strcmp(enc, "UTF-8")){ + return false; + } + return true; +} + #ifdef __cplusplus } #endif diff --git a/tests/main.cpp b/tests/main.cpp index ab677f39a..5d02450e9 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -13,7 +13,15 @@ static const char* datadir = NOTCURSES_SHARE; -bool enforce_utf8(){ +char* find_data(const char* datum){ + char* path = (char*)malloc(strlen(datadir) + 1 + strlen(datum) + 1); + strcpy(path, datadir); + strcat(path, "/"); + strcat(path, datum); + return path; +} + +bool enforce_utf8(void){ char* enc = nl_langinfo(CODESET); if(!enc){ return false; @@ -24,14 +32,6 @@ bool enforce_utf8(){ return true; } -char* find_data(const char* datum){ - char* path = (char*)malloc(strlen(datadir) + 1 + strlen(datum) + 1); - strcpy(path, datadir); - strcat(path, "/"); - strcat(path, datum); - return path; -} - static void handle_opts(const char** argv){ bool inarg = false;