/* Packs utf8 string to the buffer at the offset requested.  */
static int pack_utf8_str(const struct mqtt_utf8 *str, struct buf_ctx *buf)
/* Packs utf8 string to the buffer at the offset requested.  */
static int pack_utf8_str(const struct mqtt_utf8 *str, struct buf_ctx *buf)
{
	if ((buf->end - buf->cur) < GET_UT8STR_BUFFER_SIZE(str)) {
		return -ENOMEM;
	}
	NET_DBG(">> str_size:%08x cur:%p, end:%p",
		 (uint32_t)GET_UT8STR_BUFFER_SIZE(str), (void *)buf->cur, (void *)buf->end);
	(void)pack_uint16(str->size, buf);
	memcpy(buf->cur, str->utf8, str->size);
	buf->cur += str->size;
	return 0;
}