public function AbstractStringWrapper::setEncoding in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php \Zend\Stdlib\StringWrapper\AbstractStringWrapper::setEncoding()
Set character encoding working with and convert to
Parameters
string $encoding The character encoding to work with:
string|null $convertEncoding The character encoding to convert to:
Return value
Overrides StringWrapperInterface::setEncoding
1 method overrides AbstractStringWrapper::setEncoding()
- Native::setEncoding in vendor/
zendframework/ zend-stdlib/ src/ StringWrapper/ Native.php - Set character encoding working with and convert to
File
- vendor/
zendframework/ zend-stdlib/ src/ StringWrapper/ AbstractStringWrapper.php, line 59
Class
Namespace
Zend\Stdlib\StringWrapperCode
public function setEncoding($encoding, $convertEncoding = null) {
$supportedEncodings = static::getSupportedEncodings();
$encodingUpper = strtoupper($encoding);
if (!in_array($encodingUpper, $supportedEncodings)) {
throw new Exception\InvalidArgumentException('Wrapper doesn\'t support character encoding "' . $encoding . '"');
}
if ($convertEncoding !== null) {
$convertEncodingUpper = strtoupper($convertEncoding);
if (!in_array($convertEncodingUpper, $supportedEncodings)) {
throw new Exception\InvalidArgumentException('Wrapper doesn\'t support character encoding "' . $convertEncoding . '"');
}
$this->convertEncoding = $convertEncodingUpper;
}
else {
$this->convertEncoding = null;
}
$this->encoding = $encodingUpper;
return $this;
}