def METHOD_NAME(self, string):
    # Write the <si> element.
    attributes = []
    # Excel escapes control characters with _xHHHH_ and also escapes any
    # literal strings of that type by encoding the leading underscore.
    # So "\0" -> _x0000_ and "_x0000_" -> _x005F_x0000_.
    # The following substitutions deal with those cases.
    # Escape the escape.
    string = re_control_chars_1.sub(r"_x005F\1", string)
    # Convert control character to the _xHHHH_ escape.
    string = re_control_chars_2.sub(
        lambda match: "_x%04X_" % ord(match.group(1)), string
    )
    # Escapes non characters in strings.
    string = string.replace("\uFFFE", "_xFFFE_")
    string = string.replace("\uFFFF", "_xFFFF_")
    # Add attribute to preserve leading or trailing whitespace.
    if preserve_whitespace(string):
        attributes.append(("xml:space", "preserve"))
    # Write any rich strings without further tags.
    if string.startswith("<r>") and string.endswith("</r>"):
        self._xml_rich_si_element(string)
    else:
        self._xml_si_element(string, attributes)