Escape/replace control characters.

@param string $value

@return string
189492
private function escape($value)
    {
        if (1 !== preg_match($this->escapeCharacterPattern, $value)) {
            return htmlspecialchars($value, ENT_QUOTES);
        }

        return str_replace(
            $this->controlCharacters, $this->escapeCharacters, htmlspecialchars($value, ENT_QUOTES)
        );
    }
1372316
protected static function convertString($value)
    {
        if (strpos($value, '\\') === false) {
            return $value;
        }

        return preg_replace_callback(
            '/\\\(n|r|t|v|e|f|"|\\\)/',
            function ($match) {
                switch ($match[1][0]) {
                    case 'n':
                        return "\n";
                    case 'r':
                        return "\r";
                    case 't':
                        return "\t";
                    case 'v':
                        return "\v";
                    case 'e':
                        return "\e";
                    case 'f':
                        return "\f";
                    case '"':
                        return '"';
                    case '\\':
                        return '\\';
                }
            },
            $value
        );
    }
630664
public function escape($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        return is_string($value) ? htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset, false) : $value;
    }
720625
public function escapeLikeValue(string $value): string
    {
        // Backslash is used to escape wildcards.
        $value = str_replace('\\', '\\\\', $value);
        // Standard wildcards are underscore and percent sign.
        $value = str_replace('%', '\\%', $value);
        $value = str_replace('_', '\\_', $value);

        if ($this->dbEngine === 'mssql') {
            // MSSQL also includes character ranges.
            $value = str_replace('[', '\\[', $value);
            $value = str_replace(']', '\\]', $value);
        }

        return $value;
    }
479456
protected function _compileEscapedEchos($value)
    {
        $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->_escapedTags[0], $this->_escapedTags[1]);

        $callback = function ($matches) {
            if ($matches[1]) {
                return substr($matches[0], 1);
            }

            if (preg_match('#^[\w\.\[\]"\']+$#', $matches[2]) || preg_match('#^\\$[\w]+\(#', $matches[2])) {
                return $matches[0];
            } elseif ($this->_isSafeEchos($matches[2])) {
                return "<?= $matches[2] ?>" . (empty($matches[3]) ? '' : $matches[3]);
            } else {
                return '<?= e(' . $this->_compileEchoDefaults($matches[2]) . '); ?>' . (empty($matches[3]) ? '' : $matches[3]);
            }
        };

        return preg_replace_callback($pattern, $callback, $value);
    }
443982
private function escapeParamValue($value)
    {
        $count = 0;
        $value = str_replace('\\', '\\\\', $value);
        $value = str_replace('"', '\"', $value, $count);
        $value = str_replace("\n", '\\n', $value);
        if (false !== strpos($value, ';') || false !== strpos($value, ',') || false !== strpos($value, ':') || $count) {
            $value = '"' . $value . '"';
        }

        return $value;
    }
346795
protected function _sanitize($value)
    {
        $value      = trim(strtolower($value));
        $pattern    = '/[^a-f0-9]*/';
        return substr(preg_replace($pattern, '', $value), 0, 32);
    }
804906
protected function wrapValue($value)
    {
        if ($value === '*') {
            return $value;
        }

        $value = Str::upper($value);

        return '"' . str_replace('"', '""', $value) . '"';
    }
324634
static public function escape_script($value) 
    {
        if(is_array($value)){
            foreach ($value as $key => $val){
                $value[$key] = escape_script($val);
            }
        }else{
            $value = preg_replace ( '/\<([\/]?)script([^\>]*?)\>/si', '&lt;\\1script\\2&gt;', $value );
            $value = preg_replace ( '/\<([\/]?)iframe([^\>]*?)\>/si', '&lt;\\1iframe\\2&gt;', $value );
            $value = preg_replace ( '/\<([\/]?)frame([^\>]*?)\>/si', '&lt;\\1frame\\2&gt;', $value );
            $value = str_replace ( 'javascript:', 'javascript：', $value );
        }
        return $value;
    }
791017
protected function encode($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'encode'], $value);
        } else {
            return str_replace(['+', '%7E'], [' ', '~'], rawurlencode($value));
        }
    }
206628
protected function formatValue($value)
    {
        if (PHP_VERSION_ID < 50400) {
            return str_replace('\/', '/', json_encode($value));
        }

        return json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
    }
845899
protected function prepareRegexRule($value)
    {
        $escape = ['$' => '\$', '?' => '\?', '.' => '\.', '*' => '.*'];
        foreach ($escape as $search => $replace) {
            $value = str_replace($search, $replace, $value);
        }
        if (mb_strlen($value) > 2 && mb_substr($value, -2) == '\$') {
            $value = substr($value, 0, -2) . '$';
        }
        if (mb_strrpos($value, '/') == (mb_strlen($value) - 1)
            || mb_strrpos($value, '=') == (mb_strlen($value) - 1)
            || mb_strrpos($value, '?') == (mb_strlen($value) - 1)
        ) {
            $value .= '.*';
        }

	    if (substr($value, 0, 2) != '.*') {
		    $value = '^' . $value;
	    }
        return $value;
    }
1062321
public static function cmd($value): string
    {
        $value = Str::low($value);
        $value = preg_replace('#[^a-z0-9\_\-\.]#', '', $value);
        $value = Str::trim($value);

        return $value;
    }
909490
protected function escapeElement($value)
    {
        if (empty($value)) {
            $element = '*';
        } else {
            $element = $this->renderElement($value);
        }

        return self::escapeToken($element);
    }
921920
protected function _quote($value) {
        $char = $this->getConfig('quoteCharacter');

        return $char . str_replace($char, '', $value) . $char;
    }
85301
private function encodeNonTranslatableCharacters(string $value): string
    {
        return str_replace(
            array_keys($this->nonTranslatableCharactersHashMap),
            array_values($this->nonTranslatableCharactersHashMap),
            $value
        );
    }
1331025
protected function processLikeOperator($value)
	{
		$value = preg_quote($value);
		$value = substr($value, 0, 1) === '%' ? (substr($value, -1, 1) === '%' ? substr($value, 1, -1) : substr($value, 1) . '$') : (substr($value, -1, 1) === '%' ? '^' . substr($value, 0, -1) : $value);

		return '/' . $value . '/i';
	}