'Return a string representation of the data.
Validation is always performed, so calling this function on
invalid data may raise a ValueError.
Arguments:
framing (bool): if true, append a framing bit (see load)'

def write(self, framing=True):

    self.validate()
    def _encode(value):
        if (not isinstance(value, bytes)):
            return value.encode('utf-8')
        return value
    f = BytesIO()
    vendor = _encode(self.vendor)
    f.write(cdata.to_uint_le(len(vendor)))
    f.write(vendor)
    f.write(cdata.to_uint_le(len(self)))
    for (tag, value) in self:
        tag = _encode(tag)
        value = _encode(value)
        comment = ((tag + '=') + value)
        f.write(cdata.to_uint_le(len(comment)))
        f.write(comment)
    if framing:
        f.write('\x01')
    return f.getvalue()
