Wrapper method for encoding a value by htmlspecialchars($key, ENT_COMPAT, 'UTF-8')

@param string|number $val
The value to encode

@throws ViewException

@return string
554658
protected function htmlS($val)
    {
        if (is_array($val) || is_object($val)) {
            Throw new ViewException('It is not allowed to uses arrays or objects for htmlS() output.');
        }

        return htmlspecialchars($val, ENT_COMPAT, 'UTF-8');
    }
79434
private function encodeValue($val, $base)
    {
        $this->preOpMethodParamsCheck(array($val, $base));

        $digits = $this->baseCheck($base);

        try {

            $new = '';

            while ($this->math->comp($val, '0') > 0) {
                $qq  = $this->math->div($val, $base);
                $rem = $this->math->mod($val, $base);
                $val = $qq;
                $new = $new . $digits[$rem];
            }

            return $new;

        } catch (\Exception $e) {
            throw $e;
        }
    }
372366
protected function _buildAttr($key, $val)
    {
        $return = null;
        if (!empty($val) || $val === '0' || $key === 'value') {
            $return = ' ' . $key . '="' . $val . '"';
        }

        return $return;
    }
1345729
protected function Div( $val )
	{
	    throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
			array(
				"op:div",
				SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $this->_value ), XmlTypeCardinality::One ),
				SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val->getValue() ), XmlTypeCardinality::One )
			)
		);
	}
1130624
public function htmlEncode($data)
    {
        switch (gettype($data)) {
            case 'array':
                foreach ($data as $key => $value) {
                    $data[$key] = $this->htmlEncode($value);
                }

                break;
            case 'object':
                $data = clone $data;

                foreach ($data as $key => $value) {
                    $data->$key = $this->htmlEncode($value);
                }

                break;
            case 'string':
            default:
                $data = htmlentities($data, ENT_QUOTES, 'UTF-8');

                break;
        }

        return $data;
    }
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;
    }
846478
protected function validateCastValue($val)
    {
        try {
            $val = (string) $val;
        } catch (\Exception $e) {
            $val = json_encode($val);
        }
        switch ($this->format()) {
            case 'email':
                if (strpos($val, '@') === false) {
                    throw $this->getValidationException('value is not a valid email', $val);
                }
                break;
            case 'uri':
                if (filter_var($val, FILTER_VALIDATE_URL) === false) {
                    throw $this->getValidationException(null, $val);
                }
                break;
            case 'binary':
                $decoded = base64_decode($val, true);
                if ($decoded === false) {
                    throw $this->getValidationException(null, $val);
                }
                break;
        }

        return $val;
    }
1169307
public static function getLuhnKey($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $val = $val.'0';
        $length = strlen($val);
        $checksum = 0;
        for ($i=($length - 1); $i>=0; $i--) { 
            $digit = $val[$i];
            if ((($length - $i) % 2) == 0) {
                $digit = $digit * 2;
                if ($digit > 9) {
                    $digit = $digit - 9;
                }
            }
            $checksum += $digit;
        }
        $luhn_key = 10 - ( $checksum % 10 );
        if ($luhn_key == 10) {
            $luhn_key = 0;
        }
        return $luhn_key;
    }
1220039
function (val) {
		var parseDate = this.options.parseDate,
			ret,
			key,
			format,
			match;

		if (parseDate) {
			ret = parseDate(val);
		}
			
		if (typeof val === 'string') {
			for (key in this.dateFormats) {
				format = this.dateFormats[key];
				match = val.match(format.regex);
				if (match) {
					ret = format.parser(match);
				}
			}
		}
		return ret;
	}
832498
public function getValue($key, $view)
    {
        if (is_scalar($view)) {
            return '';
        }

        if (strpos($key, '.')) {
            return $this->getDotValue($key, $view);
        }

        if (is_object($view)) {
            if (method_exists($view, $key)) {
                return call_user_func([$view, $key]);
            } elseif (isset($view->$key)) {
                return $view->$key;
            }
            return '';
        }
        if (isset($view[$key])) {
            if (is_callable($view[$key]) && $this->isValidCallback($view[$key])) {
                return call_user_func($view[$key]);
            }
            return $view[$key];
        }
        return '';
    }
995342
protected function validateCastValue($val)
    {
        if (isset($this->descriptor()->bareNumber) && $this->descriptor()->bareNumber === false) {
            return mb_ereg_replace('((^\D*)|(\D*$))', '', $val);
        } elseif (!is_numeric($val)) {
            throw $this->getValidationException('value must be numeric', $val);
        } else {
            $intVal = (int) $val;
            if ($intVal != (float) $val) {
                throw $this->getValidationException('value must be an integer', $val);
            } else {
                return $intVal;
            }
        }
    }
1026745
public static function raw2js($val)
    {
        if (is_array($val)) {
            foreach ($val as $k => $v) {
                $val[$k] = self::raw2js($v);
            }
            return $val;
        }

        return str_replace(
            // Intercepts some characters such as <, >, and & which can interfere
            array("\\", '"', "\n", "\r", "'", '<', '>', '&'),
            array("\\\\", '\"', '\n', '\r', "\\'", "\\x3c", "\\x3e", "\\x26"),
            $val
        );
    }
1221836
public static function encode($value)
    {
        $encoded = self::safeEncode($value);
        $lastErrorCode = self::lastError();
        if ($lastErrorCode !== JSON_ERROR_NONE || $encoded === false) {
            throw new JsonEncodeException(self::lastErrorMessage(), $lastErrorCode);
        }
        return $encoded;
    }
308207
public function getFilterValue($val)
    {
        $formatter = $this->getFormatter();

        if (strlen($this->getPrefix()) > 0 && strpos($val, $this->getPrefix()) === 0) {
            $val = substr($val, strlen($this->getPrefix()));
        }
        if (strlen($this->getSuffix()) > 0 && strpos($val, $this->getSuffix()) > 0) {
            $val = substr($val, 0, -strlen($this->getSuffix()));
        }

        try {
            $formattedValue = $formatter->parse($val);
        } catch (\Exception $e) {
            return $val;
        }

        if (false === $formattedValue) {
            return $val;
        }

        return $formattedValue;
    }
517135
public function setVars($key, $value, $encode = true, $charset = 'ISO-8859')
    {
        $tag= $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT'];
        if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml, $tag) === false) {
                throw new OdfException("var $key not found in the document");
        }
        $value = $encode ? $this->recursiveHtmlspecialchars($value) : $value;
        $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value;
        $this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
        return $this;
    }
37152
public function storageVal($val)
    {
        if ($val === null) {
            // Do not json_encode NULL values
            return null;
        }

        if (!$this->l10n() && $val instanceof Translation) {
            $val = (string)$val;
        }

        if ($this->multiple()) {
            if (is_array($val)) {
                $val = implode($this->multipleSeparator(), $val);
            }
        }

        if (!is_scalar($val)) {
            return json_encode($val, JSON_UNESCAPED_UNICODE);
        }

        return $val;
    }
148890
public function getCode128CheckNum($val)
    {
        $sum = 103;
        for ($i = 0; $i < strlen($val); $i++) {
            $sum += ($i + 1) * $this->ChrToC128(ord(substr($val, $i, 1)));
        }

        $ch_num = $sum % 103;

        return $ch_num;
    }