Index: lib/libedit/chartype.c =================================================================== --- lib/libedit/chartype.c +++ lib/libedit/chartype.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -182,17 +183,11 @@ protected size_t ct_enc_width(Char c) { - /* UTF-8 encoding specific values */ - if (c < 0x80) - return 1; - else if (c < 0x0800) - return 2; - else if (c < 0x10000) - return 3; - else if (c < 0x110000) - return 4; - else - return 0; /* not a valid codepoint */ + char buf[MB_LEN_MAX]; + int size; + if ((size = wctomb(buf, c)) < 0) + return 0; + return (size_t)size; } protected ssize_t Index: lib/libedit/editline.3 =================================================================== --- lib/libedit/editline.3 +++ lib/libedit/editline.3 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 28, 2017 +.Dd November 9, 2018 .Dt EDITLINE 3 .Os .Sh NAME @@ -183,8 +183,6 @@ locale set by the application program and never uses .Xr setlocale 3 to change the locale. -The only locales supported are UTF-8 and the default C or POSIX locale. -If any other locale is set, behaviour is undefined. .Sh LINE EDITING FUNCTIONS The line editing functions use a common data structure, .Fa EditLine , Index: lib/libedit/el.h =================================================================== --- lib/libedit/el.h +++ lib/libedit/el.h @@ -56,7 +56,6 @@ #define NO_TTY 0x02 #define EDIT_DISABLED 0x04 #define UNBUFFERED 0x08 -#define CHARSET_IS_UTF8 0x10 #define NARROW_HISTORY 0x40 typedef unsigned char el_action_t; /* Index to command array */ Index: lib/libedit/el.c =================================================================== --- lib/libedit/el.c +++ lib/libedit/el.c @@ -99,10 +99,6 @@ * Initialize all the modules. Order is important!!! */ el->el_flags = 0; - if (setlocale(LC_CTYPE, NULL) != NULL){ - if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) - el->el_flags |= CHARSET_IS_UTF8; - } if (terminal_init(el) == -1) { el_free(el->el_prog); @@ -293,7 +289,7 @@ void *ptr = va_arg(ap, void *); rv = hist_set(el, func, ptr); - if (!(el->el_flags & CHARSET_IS_UTF8)) + if (MB_CUR_MAX == 1) el->el_flags &= ~NARROW_HISTORY; break; } Index: lib/libedit/read.c =================================================================== --- lib/libedit/read.c +++ lib/libedit/read.c @@ -363,17 +363,6 @@ goto again; } case (size_t)-2: - /* - * We don't support other multibyte charsets. - * The second condition shouldn't happen - * and is here merely for additional safety. - */ - if ((el->el_flags & CHARSET_IS_UTF8) == 0 || - cbp >= MB_LEN_MAX) { - errno = EILSEQ; - *cp = L'\0'; - return -1; - } /* Incomplete sequence, read another byte. */ goto again; default: