diff options
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c index 7638da31..6c130798 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) { |