summaryrefslogtreecommitdiff
path: root/src/dged/utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dged/utf8.c')
-rw-r--r--src/dged/utf8.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dged/utf8.c b/src/dged/utf8.c
index 01dcdbd..b47f5fc 100644
--- a/src/dged/utf8.c
+++ b/src/dged/utf8.c
@@ -123,7 +123,16 @@ uint32_t utf8_nbytes(uint8_t *bytes, uint32_t nbytes, uint32_t nchars) {
return bi;
}
+bool unicode_is_printable(const struct codepoint *codepoint) {
+ return ((codepoint->codepoint >= 0x20 && codepoint->codepoint <= 0x7E) ||
+ codepoint->codepoint >= 0xA0);
+}
+
uint32_t unicode_visual_char_width(const struct codepoint *codepoint) {
+ if (!unicode_is_printable(codepoint)) {
+ return 1;
+ }
+
if (codepoint->nbytes > 0) {
// TODO: use unicode classification instead
int w = wcwidth(codepoint->codepoint);