protected function escapeControlCharacters($string)
    {
        $escapedString = $this->escapeEscapeCharacter($string);

        // if no control characters
        if (!preg_match("/{$this->escapableControlCharactersPattern}/", $escapedString)) {
            return $escapedString;
        }

        return preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function($matches) {
            return $this->controlCharactersEscapingReverseMap[$matches[0]];
        }, $escapedString);
    }
protected function escapeControlCharacters($string)
    {
        $escapedString = $this->escapeEscapeCharacter($string);

        // if no control characters
        if (!preg_match("/{$this->escapableControlCharactersPattern}/", $escapedString)) {
            return $escapedString;
        }

        return preg_replace_callback("/({$this->escapableControlCharactersPattern})/", function($matches) {
            return $this->controlCharactersEscapingReverseMap[$matches[0]];
        }, $escapedString);
    }
protected function escapeControlCharacters ( $ string ) { $ escapedString = $ this -> escapeEscapeCharacter ( $ string ) ; // if no control characters if ( ! preg_match ( "/{$this->escapableControlCharactersPattern}/" , $ escapedString ) ) { return $ escapedString ; } return preg_replace_callback ( "/({$this->escapableControlCharactersPattern})/" , function ( $ matches ) { return $ this -> controlCharactersEscapingReverseMap [ $ matches [ 0 ] ] ; } , $ escapedString ) ; }
Converts PHP control characters from the given string to OpenXML escaped control characters

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_.

NOTE: the logic has been adapted from the XlsxWriter library (BSD License)
@link https://github.com/jmcnamara/XlsxWriter/blob/f1e610f29/xlsxwriter/sharedstrings.py#L89

@param string $string String to escape
@return string
Converts PHP control characters from the given string to OpenXML escaped control characters