A couple of somewhat recent changes in NetBSD's libedit permit
el_gets(3) to accept multibyte characters if the locale supports
it.
A notable user of this function is sftp(1) which will allow users to
input multibyte characters, in filenames for example, once the diff
is applied.
--
Christian
Index: eln.c
===================================================================
RCS file: /cvs/src/lib/libedit/eln.c,v
retrieving revision 1.4
diff -u -p -r1.4 eln.c
--- eln.c 20 May 2014 11:59:03 -0000 1.4
+++ eln.c 24 Dec 2015 19:34:09 -0000
@@ -74,9 +74,18 @@ el_gets(EditLine *el, int *nread)
{
const wchar_t *tmp;
- el->el_flags |= IGNORE_EXTCHARS;
+ if (!(el->el_flags & CHARSET_IS_UTF8))
+ el->el_flags |= IGNORE_EXTCHARS;
tmp = el_wgets(el, nread);
- el->el_flags &= ~IGNORE_EXTCHARS;
+ if (tmp != NULL) {
+ size_t nwread = 0;
+ int i;
+ for (i = 0; i < *nread; i++)
+ nwread += ct_enc_width(tmp[i]);
+ *nread = (int)nwread;
+ }
+ if (!(el->el_flags & CHARSET_IS_UTF8))
+ el->el_flags &= ~IGNORE_EXTCHARS;
return ct_encode_string(tmp, &el->el_lgcyconv);
}