def write_shortstr(self, s):
        """
        Write a string up to 255 bytes long (after any encoding).

        If passed a unicode string, encode with UTF-8.

        """
        self._flushbits()
        if isinstance(s, unicode):
            s = s.encode('utf-8')
        if len(s) > 255:
            raise ValueError('String too long')
        self.write_octet(len(s))
        self.out.write(s)
Write a string up to 255 bytes long (after any encoding).

        If passed a unicode string, encode with UTF-8.