docs: def write_utf8_string(self, u):
          """
          Writes a unicode object to the stream in UTF-8.
  
          @param u: unicode object
          @raise TypeError: Unexpected type for str C{u}.
          """
          if not isinstance(u, python.str_types):
              raise TypeError('Expected %r, got %r' % (python.str_types, u))
  
          bytes = u
  
          if isinstance(bytes, unicode):
              bytes = u.encode("utf8")
  
          self.write(struct.pack("%s%ds" % (self.endian, len(bytes)), bytes))