def dumpb(data: str, encoding='utf-8'):
    """
    Convert a string to its netstring representation. Returns a `bytes`
    object.

    """
    payload = data.encode(encoding=encoding)
    return b'%d:%b,' % (len(payload), payload)
