We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b57fb19 commit dbe3c30Copy full SHA for dbe3c30
src/stringbuf.h
@@ -48,11 +48,13 @@ typedef struct {
48
}
49
50
#define SB_strlen(pr) (pr##_buf.dst - pr##_buf.buf)
51
+#define SB_strlen_utf8(pr) strlen_utf8(pr##_buf.buf)
52
53
#define SB_truncate(pr,len) { \
- if ((len) < SB_strlen(pr) { \
54
- pr##_buf.dst = pr##_buf.buf + (len); \
55
- *pr##_buf.dst = '\0'; \
+ const char *src = pr##_buf.buf; \
+ for (unsigned i = 0; i < len; i++) { \
56
+ int ch = get_char_utf8(&src); \
57
+ if (!ch) break; \
58
} \
59
60
0 commit comments