diff options
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c index 17c74b94..47598ddd 100644 --- a/src/common.c +++ b/src/common.c @@ -224,6 +224,18 @@ utf8_display_len(const char * const str) return len; } +gboolean +utf8_is_printable(const wint_t ch) +{ + char bytes[MB_CUR_MAX+1]; + size_t utf_len = wcrtomb(bytes, ch, NULL); + bytes[utf_len] = '\0'; + + gunichar unichar = g_utf8_get_char(bytes); + + return g_unichar_isprint(unichar) && (ch != KEY_MOUSE); +} + char * prof_getline(FILE *stream) { @@ -597,4 +609,4 @@ strip_arg_quotes(const char * const input) } return unquoted; -} \ No newline at end of file +} |