enforce utf-8 encoding via nl_langinfo check #89

pull/108/head
nick black 5 years ago
parent f0e81ea814
commit 08d4765dc4
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -9,6 +9,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <langinfo.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <stdatomic.h> #include <stdatomic.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@ -622,6 +623,12 @@ make_nonblocking(FILE* fp){
} }
notcurses* notcurses_init(const notcurses_options* opts){ notcurses* notcurses_init(const notcurses_options* opts){
const char* encoding = nl_langinfo(CODESET);
if(encoding == NULL || strcmp(encoding, "UTF-8")){
fprintf(stderr, "Encoding (\"%s\") wasn't UTF-8, refusing to start\n",
encoding ? encoding : "none found");
return NULL;
}
struct termios modtermios; struct termios modtermios;
notcurses* ret = malloc(sizeof(*ret)); notcurses* ret = malloc(sizeof(*ret));
if(ret == NULL){ if(ret == NULL){

Loading…
Cancel
Save