Escapes values according to the output type of the rendering context. Helpers that output to
non-HTML/XML contexts should override this method accordingly.

@param string $value
@param mixed $method
@param array $options
@return mixed
972190
public function escape($value, $method = null, array $options = []) {
		$defaults = ['escape' => true];
		$options += $defaults;

		if ($options['escape'] === false) {
			return $value;
		}
		if (is_array($value)) {
			return array_map([$this, __FUNCTION__], $value);
		}
		return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
	}
867479
public function serialize($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return serialize($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return @unserialize($value);
        }

        return $value;
    }
1011313
public function formatter($value, $type, array $options = [], array $variables = [])
    {
        $options = array_replace(['wrapped' => false, 'inherit_data' => false], $options, ['data' => $value]);
        $type = isset($this->aliases[$type]) ? $this->aliases[$type] : $type;

        if (isset($options['entry_type']) && isset($this->aliases[$options['entry_type']])) {
            $options['entry_type'] = $this->aliases[$options['entry_type']];
        }

        /* @var BlockInterface $block */
        $block = $this->createNamed($type, $options);

        return $this->renderer->searchAndRenderBlock($block->createView(), 'widget', $variables);
    }
1296459
protected function stringValue($value, $jsonOptions = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
    {
        if (is_string($value)) {
            return $value;
        }

        if (method_exists($value, '__toString')) {
            return (string) $value;
        }

        if (method_exists($value, 'toArray')) {
            $value = $value->toArray();
        }

        return json_encode($value, $jsonOptions);
    }
1108295
public function mask(string $value, array $options = []) {
		$options['mask'] = $options['mask'] ?? '*';
		$temp = explode('@', trim($value));
		$length = strlen($temp[0]);
		$result = substr($temp[0], 0, floor($length / 2));
		for ($i = 0; $i <= $length - strlen($result); $i++) {
			$result.= $options['mask'];
		}
		return $result . '@' . $temp[1];
	}
1256599
public function renderValue($object, array $options = []): string
    {
        $options = array_merge(
            ['column' => $this, 'object' => $object],
            $this->getFormattingOptions(),
            $options
        );
        $accessor = PropertyAccess::createPropertyAccessor();
        try {
            $value = $accessor->getValue($object, $this->getPropertyPath());
        } catch (UnexpectedTypeException $e) {
            return '';
        }

        return $this->getValueRenderer()->renderValue($value, $options);
    }
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;
    }
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;
    }
677466
public static function Base64Decode ($value, $options = []) {
		$value = base64_decode($value);

		$to_encoding = isset($options['to_encoding']) ? $options['to_encoding'] : false;
		if ($to_encoding !== false) {
			$from_encoding = isset($options['from_encoding']) ? $options['from_encoding'] : static::DEFAULT_ENCODING;
			return mb_convert_encoding($value, $to_encoding, $from_encoding);
		}

		return $value;
	}
1261091
public function utf8($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return utf8_encode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return utf8_decode($value);
        }

        return $value;
    }
945817
public static function escape( $value )
	{
		if ( $value instanceof Htmlable )
			return $value->toHtml();

		return htmlentities( $value, ENT_QUOTES, 'UTF-8', false );
	}
956115
public function renderValue($data, array $options = []) : string
    {
        $options = array_merge($this->defaultOptions, $this->fixOptions($options));
        $result = $this->getFieldValueFromData($data, $options);

        // Currently needed for blobs from the database, but might be handy later
        // for network data and such.
        // TODO: Add support for encoding (base64, et) via $options
        if (is_resource($result)) {
            $result = stream_get_contents($result);
        }

        $rendererClass = $this->config->getProvider('renderValue');
        if (!empty($options['renderAs'])) {
            $rendererClass = __NAMESPACE__ . '\\Provider\\RenderValue\\' . ucfirst($options['renderAs']) . 'Renderer';
        }

        if (!class_exists($rendererClass)) {
            throw new InvalidArgumentException("Renderer class [$rendererClass] does not exist");
        }

        $rendererClass = new $rendererClass($this->config);
        $result = (string)$rendererClass->provide($result, $options);

        return $result;
    }
179619
public static function parse($value, $options = [])
    {
        $unserializeHandler = ini_set('unserialize_callback_func', self::class . '::handleUnserializeCallback');
        try {
            if (\PHP_VERSION_ID < 70000) {
                return Thrower::call('unserialize', $value);
            }

            return Thrower::call('unserialize', $value, $options);
        } catch (ParseException $e) {
            throw $e;
        } catch (\Throwable $e) {
        } finally {
            ini_set('unserialize_callback_func', $unserializeHandler);
        }

        throw new ParseException('Error parsing serialized value.', -1, null, 0, $e);
    }
1174514
private function escapeArray($value) {
        if (!is_array($value)) {
            return $this->escape($value);
        }
        foreach ($value as $key => $prop) {
            $value[$key] = $this->escape($prop);
        }
        return $value;
    }
678479
public function filter($value, $options = [])
    {
        if ($this->getPattern() == null) {
            $ex = new \Exception(get_class($this) . ' does not have a valid MatchPattern set.');
            throw $ex;
        }

        return preg_replace($this->getPattern(), $this->getReplacement(), $value);
    }
801681
public static function encode($value, $options = JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK)
    {
        if ($value instanceof \Traversable)
        {
            $value = \iterator_to_array($value);
        }

        return \json_encode($value, $options);
    }
118691
public function serialize($value, array $options=[])
    {
        if (is_resource($value)) {
            throw new UnsupportedParameterException('You cant serialize a resource');
        }

        if ($value === $this->serializeFalseAs) {
            throw new UnsupportedParameterException('You cant serialize '.$this->serializeFalseAs.' cause its internally used to encode false');
        }

        if ($value === false) {
            $value = $this->serializeFalseAs;
        }

        return serialize($value);
    }