Escapes potentially reserved keywords in identifiers by wrapping them
with the escape character as necessary.

@param string $word
@param string $escapeChar

@return string escaped identifier
969759
protected function escapeIdentifier($word, $escapeChar = '`')
    {
        if (is_array($word) || is_object($word) || is_numeric($word)) {
            return '';
        }

        $spaces = explode(' ', $word);
        foreach ($spaces as &$space) {
            if (strtolower($space) == 'as') {
                $space = 'AS';
            } else {
                $periods = explode('.', $space);
                foreach ($periods as &$period) {
                    // escape identifiers that are: [0-9,a-z,A-Z$_]
                    if (preg_match('/^[A-Za-z0-9_$]*$/', $period)) {
                        $period = $escapeChar.$period.$escapeChar;
                    // do not use an identifier that contains something other than:
                    //      alpha-numeric, _, $, *, /, +, -, (, )
                    } elseif (!preg_match('/^[A-Za-z0-9_$\*\/\+\-\(\)]*$/', $period)) {
                        $period = '';
                    }
                }

                $space = implode('.', $periods);
            }
        }

        return implode(' ', $spaces);
    }
767735
protected function escape(string $string): string
	{
		if($this->formatter !== null)
		{
			return $this->formatter->escape($string);
		}

		return $string;
	}
1351813
private function _unescape($string, $escapeChar)
    {
        if ($escapeChar) {
            $regexp = '/'.'\\'.$escapeChar.'/';
            $this->buffer = array('escapeChar'=> $escapeChar, 'i' => 0);

            return preg_replace_callback(
                $regexp,
                array(&$this, '_unescapeBis'),
                $string
            );

        } else {
            return $string;
        }
    }
589271
static function Escape($str, $escapeQuotes = false)
	{
		if ($escapeQuotes)
		{
			$str = str_replace(VerySimpleXmlUtil::$replacementsAttrib,VerySimpleXmlUtil::$replacementsTempAttrib,$str);
			$str = str_replace(VerySimpleXmlUtil::$reservedAttrib,VerySimpleXmlUtil::$replacementsAttrib,$str);
			$str = str_replace(VerySimpleXmlUtil::$replacementsTempAttrib,VerySimpleXmlUtil::$replacementsAttrib,$str);
		}
		else
		{
			$str = str_replace(VerySimpleXmlUtil::$replacementsText,VerySimpleXmlUtil::$replacementsTempText,$str);
			$str = str_replace(VerySimpleXmlUtil::$reservedText,VerySimpleXmlUtil::$replacementsText,$str);
			$str = str_replace(VerySimpleXmlUtil::$replacementsTempText,VerySimpleXmlUtil::$replacementsText,$str);
		}
		return $str;
	}
604141
private function escapeCharacters(array $arr, $escapeValues)
    {
        $returnArr = [];

        foreach ($arr as $key => $value) {
            $returnArr[$this->addSlashes($key)] = $escapeValues ? $this->addSlashes($value) : $value;
        }

        return $returnArr;
    }
472636
public static String escape(String raw) {
        checkNotNull(raw, "raw");
        String escaped = raw;
        escaped = escaped.replaceAll(UNESCAPED_WILDCARD_REGEX, WILDCARD_ESCAPE);
        escaped = escapeSeparators(escaped);
        return escaped;
    }
794010
public static function escape($string) {
    $escaped_chars = str_split(self::ESCAPED_CHARACTERS);
    $escaped_chars_replace = array_map(function($char) {
      return '\\' . $char;
    }, $escaped_chars);
    $string = str_replace($escaped_chars, $escaped_chars_replace, $string);
    // Ignored whitespace.
    return preg_replace('/\s+/u', ' ', $string);
  }
331552
private static int escape(char[] cc, char c, int index) {
        cc[index++] = '%';
        cc[index++] = Character.forDigit((c >> 4) & 0xF, 16);
        cc[index++] = Character.forDigit(c & 0xF, 16);
        return index;
    }
873740
public static function escape( $value, $escapeNull = true )
    {

        if( $value === null ) {
            return $escapeNull ? self::ESCAPE_CHARACTER . self::NULL_CHARACTER : '';
        }

        $value = str_replace( self::ESCAPE_CHARACTER, self::ESCAPE_CHARACTER . self::ESCAPE_CHARACTER, $value );
        $value = str_replace( self::RANGE_SEPARATOR, self::ESCAPE_CHARACTER . self::RANGE_SEPARATOR, $value );
        $value = str_replace( self::INTERVAL_SEPARATOR, self::ESCAPE_CHARACTER . self::INTERVAL_SEPARATOR, $value );

        return $value;

    }
926927
public function escape($string)
    {
        if (defined('ENT_DISALLOWED')) {
            // 'ENT_DISALLOWED' ensures that invalid characters in the given document type are replaced.
            // Otherwise control characters like a vertical tab "\v" will make the XML document unreadable by the XML processor
            // @link https://github.com/box/spout/issues/329
            $replacedString = htmlspecialchars($string, ENT_NOQUOTES | ENT_DISALLOWED);
        } else {
            // We are on hhvm or any other engine that does not support ENT_DISALLOWED.
            //
            // @NOTE: Using ENT_NOQUOTES as only XML entities ('<', '>', '&') need to be encoded.
            //        Single and double quotes can be left as is.
            $escapedString =  htmlspecialchars($string, ENT_NOQUOTES);

            // control characters values are from 0 to 1F (hex values) in the ASCII table
            // some characters should not be escaped though: "\t", "\r" and "\n".
            $regexPattern = '[\x00-\x08' .
                            // skipping "\t" (0x9) and "\n" (0xA)
                            '\x0B-\x0C' .
                            // skipping "\r" (0xD)
                            '\x0E-\x1F]';
            $replacedString = preg_replace("/$regexPattern/", '�', $escapedString);
        }

        return $replacedString;
    }
791285
def escape_chars(text, chars):
    """"""
    text = str(text)
    chars = list(set(chars))
    if '\\' in chars:
        chars.remove('\\')
        chars.insert(0, '\\')
    for ch in chars:
        text = text.replace(ch, '\\' + ch)
    return text
5241
def add_escape(self, idx, char):
        

        self.fmt.append_text(self.fmt._unescape.get(
            self.format[self.str_begin:idx], char))
760719
def escapeQueryTerm(self, term):
        
        reserved = [
            '+',
            '-',
            '&',
            '|',
            '!',
            '(',
            ')',
            '{',
            '}',
            '[',
            ']',
            '^',
            '"',
            '~',
            '*',
            '?',
            ':',
        ]
        term = term.replace('\\', '\\\\')
        for c in reserved:
            term = term.replace(c, "\%s" % c)
        return term
151788
public function escape_string($string)
    {
        if (!$this->connection) {
            return $string;
        }

        if ($string === null) {
            return $string;
        }
        return $this->connection->escape_string($string);
    }
809621
public char getDelimiterEscapeChar(char ch) throws DefinitionException {
      if (ch == 'E')
        return escapeCharacter;
      else if (ch == 'F')
        return fieldDelimiter;
      else if (ch == 'S')
        return componentDelimiter;
      else if (ch == 'T')
        return subComponentDelimiter;
      else if (ch == 'R')
        return repetitionDelimiter;
      else
        throw new DefinitionException("internal error in getDelimiterEscapeChar");
    }
457823
public function like($x, $y/*, ?string $escapeChar = null */)
    {
        return $this->comparison($x, 'LIKE', $y) .
            (func_num_args() >= 3 ? sprintf(' ESCAPE %s', func_get_arg(2)) : '');
    }
245694
private function quoteReservedWord(string $word): string
    {
        if (null === $this->platformReservedWord) {
            try {
                $this->platformReservedWord = $this->connection->getDatabasePlatform()->getReservedKeywordsList();
            } catch (DBALException $exception) {
                // Add the not support key word list, if the platform has not a list of keywords.
                $this->platformReservedWord = new NotSupportedKeywordList();
            }
        }

        if (false === $this->platformReservedWord->isKeyword($word)) {
            return $word;
        }

        return $this->connection->quoteIdentifier($word);
    }