def write_string(self, string):
        """ Writes a string to the underlying output file as a buffer of chars with UTF-8 encoding. """
        buf = bytes(string, 'UTF-8')
        length = len(buf)
        self.write_int(length)
        self.write(buf)