enforce utf-8 encoding via nl_langinfo check #89

This commit is contained in:
nick black 2019-12-03 20:26:54 -05:00
parent f0e81ea814
commit 08d4765dc4
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -9,6 +9,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <langinfo.h>
#include <sys/poll.h>
#include <stdatomic.h>
#include <sys/ioctl.h>
@ -622,6 +623,12 @@ make_nonblocking(FILE* fp){
}
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;
notcurses* ret = malloc(sizeof(*ret));
if(ret == NULL){