glib-aux: add nm_str_buf_utf8_validate() helper

(cherry picked from commit b15dfe0365)
This commit is contained in:
Thomas Haller 2021-07-09 09:22:31 +02:00
parent bbfdbf5f76
commit c5f8173072
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -504,4 +504,11 @@ nm_str_buf_destroy(NMStrBuf *strbuf)
#define nm_auto_str_buf nm_auto(nm_str_buf_destroy)
static inline gboolean
nm_str_buf_utf8_validate(NMStrBuf *strbuf)
{
_nm_str_buf_assert(strbuf);
return strbuf->_priv_len == 0 || g_utf8_validate(strbuf->_priv_str, strbuf->_priv_len, NULL);
}
#endif /* __NM_STR_BUF_H__ */