protected function Escaper::toUtf8 in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-escaper/src/Escaper.php \Zend\Escaper\Escaper::toUtf8()
Converts a string to UTF-8 from the base encoding. The base encoding is set via this class' constructor.
Parameters
string $string:
Return value
string
Throws
Exception\RuntimeException
3 calls to Escaper::toUtf8()
- Escaper::escapeCss in vendor/
zendframework/ zend-escaper/ src/ Escaper.php - Escape a string for the CSS context. CSS escaping can be applied to any string being inserted into CSS and escapes everything except alphanumerics.
- Escaper::escapeHtmlAttr in vendor/
zendframework/ zend-escaper/ src/ Escaper.php - Escape a string for the HTML Attribute context. We use an extended set of characters to escape that are not covered by htmlspecialchars() to cover cases where an attribute might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE).
- Escaper::escapeJs in vendor/
zendframework/ zend-escaper/ src/ Escaper.php - Escape a string for the Javascript context. This does not use json_encode(). An extended set of characters are escaped beyond ECMAScript's rules for Javascript literal string escaping in order to prevent misinterpretation of Javascript as HTML…
File
- vendor/
zendframework/ zend-escaper/ src/ Escaper.php, line 314
Class
- Escaper
- Context specific methods for use in secure output escaping
Namespace
Zend\EscaperCode
protected function toUtf8($string) {
if ($this
->getEncoding() === 'utf-8') {
$result = $string;
}
else {
$result = $this
->convertEncoding($string, 'UTF-8', $this
->getEncoding());
}
if (!$this
->isUtf8($result)) {
throw new Exception\RuntimeException(sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result));
}
return $result;
}