glib-aux: add nm_str_buf_append_unichar() helper

This commit is contained in:
Thomas Haller 2021-05-06 17:31:59 +02:00
parent 7065d75b91
commit 1556732ef0
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -207,6 +207,17 @@ nm_str_buf_append_c_hex(NMStrBuf *strbuf, char ch, gboolean upper_case)
strbuf->_priv_str[strbuf->_priv_len++] = nm_hexchar((guchar) ch, upper_case);
}
static inline void
nm_str_buf_append_unichar(NMStrBuf *strbuf, gunichar wc)
{
int l;
nm_str_buf_maybe_expand(strbuf, 6 + 1, FALSE);
l = g_unichar_to_utf8(wc, &strbuf->_priv_str[strbuf->_priv_len]);
nm_assert(l > 0 && l <= 6);
strbuf->_priv_len += (gsize) l;
}
static inline void
nm_str_buf_append_len(NMStrBuf *strbuf, const char *str, gsize len)
{