public function Native::setEncoding in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-stdlib/src/StringWrapper/Native.php \Zend\Stdlib\StringWrapper\Native::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 AbstractStringWrapper::setEncoding
File
- vendor/
zendframework/ zend-stdlib/ src/ StringWrapper/ Native.php, line 67
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 ($encodingUpper !== strtoupper($convertEncoding)) {
$this->convertEncoding = $encodingUpper;
}
if ($convertEncoding !== null) {
if ($encodingUpper !== strtoupper($convertEncoding)) {
throw new Exception\InvalidArgumentException('Wrapper doesn\'t support to convert between character encodings');
}
$this->convertEncoding = $encodingUpper;
}
else {
$this->convertEncoding = null;
}
$this->encoding = $encodingUpper;
return $this;
}